简体   繁体   中英

Enabling CTRL+Z property in masked edit textbox using VB.Net

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM