richtextbox and the undo method

Illusion

Centurion
Joined
Aug 7, 2003
Messages
105
Location
Uk
Hi,

I wondered if someone could help/point me in the right direction :)

I add some text to a richtextbox and call the undo method and nothing happens.. however if i type into the box and call the undo method it works..
what am I missing here :| ..

I add the text by :

richtextbox1.text = "blah"
richtextbox1.text = richtextbox1.text + " and more blah"

so I then click on the undo button and nothing happens.. im guessing its not registering to be undone.. but how do I go about getting it to be accepted?
I did try cutting and pasting, but thats just a dirty fix.. any clean ones?

Thanks
 
you should be using AppendText not " richtextbox.text = "
if you use the following you should see it work...
Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        RichTextBox1.AppendText("blabla ")
        RichTextBox1.AppendText("something else")
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        RichTextBox1.Undo()
    End Sub
 
Back
Top