system keys

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am creating a control, based on TextBox. How do I filter DEL and other system keys
Now I do it by trapping WM_KEYDOWN in WndProc override, but is not there a .NET way

Thank you
 
Even if I override OnKeyPress, DEL is not filtered

OnKeyPress(...


e.Handled=true; // this will disable key input to the box, but DEL still work
}
 
* "Ed Kaim said:
You can handle the KeyPress event.

\\\
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar = Chr(8) Then
e.Handled = True
End If
End Sub
///
 
Override OnKeyDown like this

OnKeyDown(...)
{
if e.KeyCode = Keys.Delete
e.Handled = true;
else
base.OnKeyDown(e);
}

(I'm not that familiar with C# so the syntax may be incorrect)

This should filter out the DEL key. You'll have to handle the rest of the
keys
that you want to filter in a similar way

As you have noticed the DEL key doesn't generate a keypress event

/claes
 
Back
Top