Click here to Skip to main content
15,909,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to disable backspace in a textbox in vb.net wpf?


I've already tried
VB
Private Sub TextBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
       If e.KeyCode = Keys.Back Or e.KeyCode = Keys.Delete Then
           e.SuppressKeyPress = True
       End If
   End Sub


but it doesn't work in WPF. I dont know why.
Posted
Updated 25-Aug-13 7:26am
v2

Refer - Key press event in WPF[^].

The code is in C#, but you can use the same logic.
 
Share this answer
 
For this use



VB
Private Sub TextBox1_PreviewKeyDown(sender As Object, e As System.Windows.Input.KeyEventArgs) Handles TextBox1.PreviewKeyDown
       If e.Key = Key.Back Then
           e.Handled = True
       End If



Also have a look at
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.previewkeydown.aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900