473,387 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Scroll To Bottom Of RichTextBox

How do I scroll to the bottom of RichTextBox

Currently tried

RichTextBox1.SelectionStart=len(RichTextBox1.text)
RichTextBox1.ScrollToCaret

This does not work.

What is the best what to accomplish this

Thanks,

Dan
Nov 21 '05 #1
1 5460
* "Daniel Friend" <da*@donotspam.com> scripsit:
How do I scroll to the bottom of RichTextBox


From my FAQ (<URL:http://dotnet.mvps.org/dotnet/faqs/>):

When using a RichTextBox control for displaying logging information, it is
useful to scroll the recently added line into view. There are two ways to
accomplish this:

\\\
Private Const WM_VSCROLL As Int32 = &H115
Private Const SB_BOTTOM As Int32 = 7

Private Declare Auto Function SendMessage Lib "user32.dll" ( _
ByVal hwnd As IntPtr, _
ByVal wMsg As Int32, _
ByVal wParam As Int32, _
ByVal lParam As Int32 _
) As Int32

Private Sub AddLine(ByVal Destination As RichTextBox, ByVal Text As String)
With Destination
.AppendText(Text & ControlChars.NewLine)
SendMessage(Destination.Handle, WM_VSCROLL, SB_BOTTOM, 0)
End With
End Sub
///

- or -

\\\
Dim ctr As Control = Me.ActiveControl
With Me.RichTextBox1
.Focus()
.AppendText("Hello World!")
.ScrollToCaret()
End With
ctr.Focus()
///

The 2nd solution has a side-effect: Setting the focus to the
RichTextBox control may raise validation events.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Lasse Edsvik | last post by:
Hello I was wondering if you guys could tell me to scroll the richtextbox's content to bottom if there it has enough text to make a scroll that is. everytime i append text to it i would like...
2
by: Joseph Lee | last post by:
Hi, I am trying to find the command to scroll the richtextbox to the latest appended string at the bottom. I have tried update, refresh and scroll to caret but it does not seem to work Thanks...
0
by: Markus Mehlan | last post by:
Dear all, i want to scroll a richtextbox with code. The richtextbox hasn't any scrollbars. I want to scroll the text continously not line by line. Has someone an idea or a code snippet? ...
1
by: Jesper | last post by:
Hi, Is it possible to scroll a RichTextBox programmatically to a given text selection in it, such that the selected text becomes viewable. regards. Jesper.
2
by: JonnyT | last post by:
I searched high and low for an answer on how to auto scroll a richtextbox and now I finally have it. Since it took me a while to get a good efficient way of doing it that didn't require focus to...
4
by: D. Yates | last post by:
Hi, When a RichTextBox control doesn't have focus, it DOES NOT scroll to the last line that is added; however, if it does have focus, it WILL scroll to the last line added. I want to stop and...
6
by: UJ | last post by:
I've got a multiline textbox that I'm using to display messages. Is there an easy way to have it scroll to the end after I add a line to the text of the box? TIA - Jeff.
1
by: dotnetnoob | last post by:
i have a Dialog form with richtextbox that basically display a legal agreement and when the user drag the scroll thumb down to the end of scrolling which suppose to mean the user have read it then...
1
by: teo | last post by:
hallo I'm with vs2005 fw 2..0 is there a way to "freeze" the richtextbox, so to avoid user from editing it? I can Enable=False, but it no more scrolls and the font-color becomes grayed. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.