A regular textbox control would work perfectly fine for me if only as I
append text to it, it scrolled to the bottom so the newly added info is
visible and older info can scroll off the top of the textbox.
can I make a text box do this? or is there another control I could use to do
this? I need a control to use as an output screen that will be coninually
written to by several other components of the program. A 'status' output, if
you will.
any input would be greatly appreciated, thanks.
--
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
A brute awe as you,
a Metallic hag entity, eat us.
"djc" <no...@nowhere.com> wrote in message
news:eXHCh%23HPGH...@TK2MSFTNGP09.phx.gbl...
"Kevin Spencer" <ke...@DIESPAMMERSDIEtakempis.com> wrote in message
news:%23NngeUJ...@TK2MSFTNGP09.phx.gbl...
This code may not be highly performant, but it works. Note: This uses
the Lines property of the textbox, so in order to recognize that text
has been appended, you need to add it on a new line (after CrLf)
For best results, set the vertical size of the Textbox such that it
only the required no. of lines is visible. I had to use a Boolean
variable "working" to prevent recursion, since changing the text within
the sub triggers the TextChanged event again.
I am also open to comments on how this code can be improved.
------------------------------------------------------
Dim MaxLines as Integer = 10
Dim LineCount As Integer
Dim working As Boolean = False
Private Sub Txt1_TextChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Txt1.TextChanged
If working = True Then
Exit Sub
Else
'First count the no. of lines in the textbox
LineCount = Txt1.Lines.GetUpperBound(0)
If LineCount > MaxLines Then
working = True
Dim arrLines() As String = Txt1.Lines
'Txt1.
Dim i As Integer
Dim currText As String
'Remove the first line and leave all other text intact.
For i = 1 To (arrLines.GetUpperBound(0) - 1)
currText += arrLines(i) & vbCrLf
Next
Txt1.Text = currText
'Position the caret at the bottom of the text.
Txt1.SelectionStart = Txt1.Text.Length
Txt1.ScrollToCaret()
working = False
End If
End If
End Sub
------------------------------------------------------
HTH,
Regards,
Cerebrus.
"Cerebrus" <zor...@sify.com> wrote in message
news:1141188077.5...@e56g2000cwe.googlegroups.com...