Set the caret to the length of the text property, focus the text box, and
then call "ScrollToCaret"
> How can I scroll a Rich Text Box down to a certain line in Visual Basic.NET
> v7.
>
> Ted
Unforutnately I think you need an API call to do it. Not too hard to do,
but a bit obscure. You need to send the EM_LINEINDEX message to the text
control. This will return the character index of the first character of the
specified line. Something like:
[DllImport("user32.dll", EntryPoint="SendMessage", CharSet = CharSet.Auto)]
private static extern int SendMessageInt(IntPtr hWnd, UInt32 Msg, Int32
wParam, Int32 lParam);
private const int EM_LINEINDEX= 0xBB;
public static int GetCharFromLineNumber(TextBoxBase control, int lineNumber)
{
return SendMessageInt(control.Handle, EM_LINEINDEX, lineNumber, 0);
}
should do the trick. Once you have the char position, you can set the
current position and call ScrollToCaret() to get there.
Tom Clement
Apptero, Inc.
P.S. The docs say:
The EM_LINEFROMCHAR message retrieves the index of the line that contains
the specified character index in a multiline edit control. A character index
is the zero-based index of the character from the beginning of the edit
control. You can send this message to either an edit control or a rich edit
control.
> How can I scroll a Rich Text Box down to a certain line in Visual Basic.NET
> v7.
>
> Ted