简体   繁体   English

使用VB.Net在屏蔽的编辑文本框中启用CTRL + Z属性

[英]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. 我在使用vb.net开发的Windows应用程序中使用带遮罩的编辑文本框。

In normal text boxes (CTRL+Z- to revert back to original value) is working fine. 在普通文本框中(CTRL + Z-恢复为原始值)工作正常。 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. 此Ctrl + Z应该提供与普通文本框相同的功能。

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 : 您可以通过对Leave事件进行编程来使用变量来存储当前文本,并在KeyDown事件中检查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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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