Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RichTextBox question

Status
Not open for further replies.

Perilous1

IS-IT--Management
Mar 10, 2005
171
US
The snippet of code below is pretty standard for appending new text into a rtb. How would I go about arranging it so that all new text is prepended to the top of the rtb rather than to the bottom?

Private Sub clientLogMessage(ByVal Message As String)
Delegates.RichTextBoxes.appendText(Me, rtbClient, vbCrLf & Message)
End Sub
 
Umm...while I don't know everything I wouldn't call that a pretty standard way of doing it as I've never seen anything like it nor can find anything like it so I can't tell you how to change it but.

RichTextBox1.Text = Message & RichTextBox1.Text

If you need to delegate it so to avoid cross threading then you could do something like.
Code:
    Public Sub RichTextAppendBefore(ByVal text As String)
        If Me.InvokeRequired Then
            Me.BeginInvoke(New delRTAB(AddressOf RTAB), text)
        Else
            RTAB(text)
        End If
    End Sub

    Private Delegate Sub delRTAB(ByVal text As String)
    Private Sub RTAB(ByVal text As String)
        RichTextBox1.Text = text & RichTextBox1.Text
    End Sub
It could be something I just don't know but the above is the best I can help.

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top