View Single Post
  #2 (permalink)  
Old 01-14-2009, 2:55 PM
MattP MattP is offline
VB.NET Forum Idol
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Feb 2008
Location: USA
Posts: 877
Reputation: 500
MattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond repute
Default

Size your RichTextBox to 10 lines in height. ScrollToCaret will cause the RichTextBox to scroll to the bottom where you just added the line.

Code:
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
Reply With Quote