如何只从richtextbox获取文本的显示部分

时间:2011-06-28 06:51:56

标签: c# richtextbox

我只希望以字符串形式显示来自richtext框的文本

我通过

找到了最初的亚麻布和最后的亚麻布
Point pos = new Point(0, 0);
int firstIndex = this.GetCharIndexFromPosition(pos);
int firstLine = this.GetLineFromCharIndex(firstIndex);

//now we get index of last visible char and number of last visible line
pos.X = ClientRectangle.Width;
pos.Y = ClientRectangle.Height;
int lastIndex = this.GetCharIndexFromPosition(pos);
int lastLine = this.GetLineFromCharIndex(lastIndex);

//this is point position of last visible char, 
//we'll use its Y value for calculating numberLabel size
pos = this.GetPositionFromCharIndex(lastIndex);

如何获取过滤器rtb文本并仅获取文本的显示部分?

1 个答案:

答案 0 :(得分:0)

我相信你只需使用(boxname).Text属性。和(boxname).RTF,如果你想要它RTF格式。所以在你的例子中:

string text = this.Text;
相关问题