как получить только отображаемую часть текста из поля richtext - PullRequest
0 голосов
/ 28 июня 2011

Я хочу отображать только текст из поля 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 голосов
/ 28 июня 2011

Полагаю, вы просто используете свойство (boxname) .Text.И (boxname) .RTF, если вы хотите, чтобы он был в формате RTF.Итак, в вашем примере:

string text = this.Text;
...