Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / General / November 2003

Tip: Looking for answers? Try searching our database.

Scroll to line in Rich Text Box

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ted - 09 Nov 2003 22:02 GMT
How can I scroll a Rich Text Box down to a certain line in Visual Basic.NET
v7.

Ted
Keith Patrick - 10 Nov 2003 17:31 GMT
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
Tom Clement - 12 Nov 2003 04:52 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.