I want only displayed text from richte开发者_如何转开发xt 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?
I believe you just use the (boxname).Text property. And (boxname).RTF if you want it RTF-formatted. So in your example:
string text = this.Text;
精彩评论