I'm use this code for block the dollar button shift+4 = $. On this table http://expandinghead.net/keycode.html the $ is code 36
now the code on keydown:
if (e.KeyValue == 36)
{
e.Handled = true;
}
code not work why?
I'm use this code for block the dollar button shift+4 = $. On this table http://expandinghead.net/keycode.html the $ is code 36
now the code on keydown:
if (e.KeyValue == 36)
{
e.Handled = true;
}
code not work why?
Why not on KeyPress event
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == '$')
{
e.Handled = true;
}
}
This is because you first press shift and then 4, so you will get the code of shift (key value 16) separately when using KeyDown event.
To achieve what you want, use KeyPress event, not KeyDown. KeyPress will register the character you typed ($), not individual keys pressed.
if (e.KeyChar == '$')
{
e.Handled = true;
}