Disable the effect of DEL key.
Hi Guys,
Is there anyway by which I can disable the effect of DEL key using VB.Net. I am developing a desktop application. What I want is the user should not be able to del key or ctrl-X or ctrlC when the focus is on the text box.
Any answers?
Please let me know.
Regards,
Samir.
Re: Disable the effect of DEL key.
VB Code:
Private Sub MyTextBox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyCode = Keys.Delete Then
End If
If e.Control And e.KeyCode = Keys.C Then
End If
If e.Control And e.KeyCode = Keys.V Then
End If
End Sub
Re: Disable the effect of DEL key.
Thanx a lot buddy.
I tried the same thing but it didn't work. Probaby because i traped the keypress and the keyup events.
Regards,
Samir.
Re: Disable the effect of DEL key.
If you want to disable a Key in KeyDown/KeyPress or KeyUp events, you should use e.Handled = true to let windows know that the key was handled by the window. Like this
VB Code:
If e.KeyCode = Keys.Delete Then
e.Handled = True
End If