Richtextbox formatting between events

Hello all,

I am using a richtextbox to read information in when a use clicks a button. on every click i need to display a differet color for the text. What happens is that all my previous formating is lost and only the latest is saved. Is there a way to prevent this from happening.

I am currently using the following method to add the new text to the box


ImportTextBox.Text &= NewText

I then select the new text and apply the formatting, like i said previously only the latest changes stick the others are removed. Any help with this would be great. Thanks

[783 byte] By [KevinMcKinney] at [2007-12-16]
# 1


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim MyString As String = "This is a Test"

Me.RichTextBox1.AppendText(MyString)

Me.RichTextBox1.SelectionStart = Me.RichTextBox1.TextLength - MyString.length

Me.RichTextBox1.SelectionLength = MyString.Length

If Me.CheckBox1.CheckState = CheckState.Checked Then

Me.RichTextBox1.SelectionColor = Color.Blue

Else

Me.RichTextBox1.SelectionColor = Color.Green

End If

Me.RichTextBox1.SelectionStart = Me.RichTextBox1.TextLength

End Sub



DMan1 at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Base Class Library...

.NET Development

Site Classified