Limit RichtextBox

Kelvin Perez

New member
Joined
Jan 14, 2009
Messages
3
Programming Experience
Beginner
Hi:

I'm new to VB2008 (from old VB6 school). I'm going crazy with a small app I'm making. I'm running a loop and displaying the results in a RichtextBox but I want to limiting the display to always show the last 10 lines (Like the previous line go up beyond the user's view).
:confused:

Any suggestions will be greatly appreciated.
Best Regards:
KP
 
Size your RichTextBox to 10 lines in height. ScrollToCaret will cause the RichTextBox to scroll to the bottom where you just added the line.

VB.NET:
Public Class Form1

	Dim i As Integer = 1

	Private Sub uxAddLine_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
	Handles uxAddLine.Click

		If Me.RichTextBox1.Text.Length = 0 Then
			Me.RichTextBox1.AppendText("Line: " & i)
		Else
			Me.RichTextBox1.AppendText(Environment.NewLine & "Line: " & i)
		End If

		Me.RichTextBox1.ScrollToCaret()

		i += 1

	End Sub

End Class
 
Cool!!! Thanks!!! Will try it ASAP....
:D

Just one question: By setting it to 10 lines, will the remaining lines be deleted or just scrolled?
 
I manually adjusted the height to only show 10 lines worth of data (135px worked well for my default font).

As I was clicking my button to add lines the additional lines were scrolled out of view.
 
GREAT!!!!!!!!!!! It worked perfectly!!!! I'm so glad.....and so dumb.....I was going crazy saving lines to arrays and re-arranging the arrays and clearing the box and it was so simple.....
:eek:

Thanks a lot for your help....I really appreciate it!!!!!!!
:D
 
Back
Top