Home Forums WinForms controls Other WinForms controls Wintextbox undo

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #18126 |

    hello.
    I use a tryal version 3.0
    i try to make a undo operation on Wintextbox.

    form_Load
    AddHandler Me.WinTextBox1.TextBoxArea.KeyUp, AddressOf WinTextBox1_KeyPress
    end sub

    Private Sub Wintextbox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles WinTextBox1.KeyPress
    If e.KeyChar = Microsoft.VisualBasic.ChrW(27) Then
    Me.Wintextbox1.TextBoxArea.Undo()
    End If
    End Sub
    then copy and paste work fine , but undo don’t work.
    It’s because it’s a tryal?

    Imported from legacy forums. Posted by isabel oliveira (had 2303 views)

    User (Old forums)
    Member
    Post count: 23064

    The TextBoxArea does not support the Undo() method. Now it is possible to implement one fairly easily, doing something like this :

    C#:

    private void Form1_Load(object sender, System.EventArgs e)
    {
    winTextBox1.TextBoxArea.GotFocus += new EventHandler( TextBoxArea_GotFocus );
    winTextBox1.TextBoxArea.KeyUp += new KeyPressEventHandler( TextBoxArea_KeyUp );
    }

    private string m_CachedText = string.Empty;

    private void TextBoxArea_KeyUp(object sender, KeyEventArgs e)
    {
    if( e.KeyCode == Keys.Escape )
    {
    winTextBox1.TextBoxArea.Text = m_CachedText;
    winTextBox1.TextBoxArea.Select( 0, winTextBox1.TextBoxArea.Text.Length );
    }
    }

    private void TextBoxArea_GotFocus(object sender, EventArgs e)
    {
    m_CachedText = winTextBox1.TextBoxArea.Text;
    }

    Imported from legacy forums. Posted by André (had 2960 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.