RichTextBox Display the latest line

RichTextBox Display the latest line

Post by hirf-spam- » Fri, 16 Jul 2004 08:13:08

* XXXX@XXXXX.COM (dale zhang) scripsit:


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
.AppendText("Hello World!")
End With

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

Herfried K. Wagner [MVP]
<URL: ;

1. Display a file line by line but not blank lines.

2. Display every 3rd category name but still display latest month

I don't know if this is possible or not. I have a chart with many months of
data. To make the chart more readable, I have it set so that only the name of
every 3rd month displays on the x axis. As we add the next month's data, the
name of that month does not display because of that setting. The boss does
not want to drop off the first month of the data. Is there any way to have
every third month appear but still always have the last month display? This
is a chart that will be updated monthly and continue to grow.

Any suggestions?


3. Does Setting RichTextBox.SeletcionStart Change RichTextBox.Text ?!?!?

4. RichTextBox Line at cursor question

5. Addling non editable line numbers to richtextbox in c#

6. How to automatically scroll to a specified line in RichTextBox?

7. going to last line of text in a RichTextBox.

8. Add line numbers to richtextbox

9. Lines in RichTextBox

10. What is end-of-line character(s) in a RichTextBox.Text string?

11. How to set value to Richtextbox.Lines ??

12. Using GDI+ to draw lines and points inside RichTextBox...

13. Replacing a line in a multiline RichTextBox

14. now can i know the line size in a richTextBox control ??

15. copy last line of richtextbox and paste into another