简体   繁体   English

如何从富文本框中仅获取文本的显示部分

[英]how to get only the displayed part of text from richtext box

I want only displayed text from richtext box in string form我只想以字符串形式显示富文本框中的文本

I have found the initial linenumber and last linenumber through我找到了初始行号和最后一个行号

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);

how can I get filter rtb text and get only the displayed part of text?如何获取过滤器 rtb 文本并仅获取文本的显示部分?

I believe you just use the (boxname).Text property.我相信您只使用 (boxname).Text 属性。 And (boxname).RTF if you want it RTF-formatted.和 (boxname).RTF 如果你想要 RTF 格式。 So in your example:所以在你的例子中:

string text = this.Text;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM