2011-06-28 150 views
0

我只想在字符串形式顯示的文本從富文本框獲得純文本的顯示部分如何從富文本框

我發現通過

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文本,並只獲取文本的顯示部分?

回答

0

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

string text = this.Text;