views:

34

answers:

1

Hi all,

I am using a masked edit text box in my windows application that was developed by using vb.net.

In normal text boxes (CTRL+Z- to revert back to original value) is working fine. But In case of Masked Edit Textboxes its not working fine.

Can any one please help me about this.

This ctrl+Z should provide the functionality as same as normal textbox.

A: 

You can use a variable to store the current text by programming the Leave event and check during the KeyDown event for the combination of Control+Z:

Dim oldText As String = ""

Private Sub MaskedTextBox1_KeyDown(ByVal sender As Object, _
  ByVal e As System.Windows.Forms.KeyEventArgs) _
  Handles MaskedTextBox1.KeyDown

    If e.Control AndAlso e.KeyCode = Keys.Z Then MaskedTextBox1.Text = oldText

End Sub

Private Sub MaskedTextBox1_Leave(ByVal sender As Object, _
  ByVal e As System.EventArgs) _
  Handles MaskedTextBox1.Leave

    oldText = MaskedTextBox1.Text

End Sub
Anax
But it doesn't provide the functionality like textbox.
Ramesh
You asked for CTRL+Z to work and I provided that code for you. If you want other functionality enabled, you need to either specify more clearly what you need or to find it out yourself. As far as the question is concerned, I believe my answer was correct and working.
Anax