Hello!Need your help!
How to get displayed text in RichTextBox? I mean if RichTextBox is scrolled to the end, I'd like to receive only those lines, which are visible for me.
P.S.It'll be enough to get fisrt displayed string
Hello!Need your help!
How to get displayed text in RichTextBox? I mean if RichTextBox is scrolled to the end, I'd like to receive only those lines, which are visible for me.
P.S.It'll be enough to get fisrt displayed string
Look at sending the message EM_GETFIRSTVISIBLELINE via the SendMessage API function.
From eggcafe:
" The idea is to get the text under the scrollbar visible area.
You need to find out the height of the richtextbox and determine the text's height by using the TextHeight Property of the control. divide the height of the control by text's height.
By this, you can determine the maximum number of lines that can be accomodated in the richtextbox control.
Hope this resolves or atleast takes you near. "
Taken from http://www.eggheadcafe.com/community/aspnet/2/10073516/how-to-select-the-visible.aspx
You want to use RichTextBox.GetCharIndexFromPosition(). To get the index of the first visible character, pass new Point(0, 0), the upper left corner of the RTB client area. To get the index of the last visible character, pass new Point(rtb.ClientSize.Width, rtb.ClientSize.Height). RichTextBox.Text.Substring() then gets you all visible text.
If necessary, you can use RichTextBox.GetLineFromCharIndex() to translate the character indexes to line numbers.