如何从richtext框中只获取文本的显示部分
本文关键字:取文本 获取 显示部 richtext | 更新日期: 2023-09-27 18:00:29
我只想以字符串形式显示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文本并只获取文本的显示部分?
我相信您只需要使用(boxname).Text属性。和(箱名)。RTF,如果你想格式化的话。所以在你的例子中:
string text = this.Text;