It:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.keypress.aspx
... indicates that I should have access to e.KeyCode in the KeyPress event, but it seems to me not. I am trying to resolve only 1,2,3 and backspace:
private void textBoxQH1_KeyPress(object sender, KeyPressEventArgs e) { if ((e.KeyChar != '1') && (e.KeyChar != '2') && (e.KeyChar != '3') && (e.KeyChar != (Keys.Back))) { e.Handled = true; } }
... but "e." doesnβt show the value of "KeyCode", as shown in the example, and trying to KeyChar with Keys.Back scolds me, "Operator"! = "cannot be applied to operands of type" char "and" System.Windows.Forms. Keys "
So how can I do this?
source share