T
Tim
Hi Guys,
I want to know how to tell if the shift key is held down when another
key is pressed.
I am using the following code to make sure that only numbers, backspace
and decimal are allowed in a text box. I want to use the decimal on the
It can tell that the key is pressed but if the user holds the shift key
down then a > is inserted into the text box. How do I tell?
Thanks
Tim
// Determine whether the keystroke is a number from the top of the keyboard.
if (e.KeyCode < Keys.D0 || e.KeyCode > Keys.D9)
{
// Determine whether the keystroke is a number from the keypad.
if (e.KeyCode < Keys.NumPad0 || e.KeyCode > Keys.NumPad9)
{
// Determine whether the keystroke is a backspace.
if(e.KeyCode != Keys.Back && e.KeyCode != Keys.Decimal)
{
// A non-numerical keystroke was pressed.
// Set the flag to true.
nonNumberEntered = true;
}
}
}
I want to know how to tell if the shift key is held down when another
key is pressed.
I am using the following code to make sure that only numbers, backspace
and decimal are allowed in a text box. I want to use the decimal on the
key, OemDecimal.
It can tell that the key is pressed but if the user holds the shift key
down then a > is inserted into the text box. How do I tell?
Thanks
Tim
// Determine whether the keystroke is a number from the top of the keyboard.
if (e.KeyCode < Keys.D0 || e.KeyCode > Keys.D9)
{
// Determine whether the keystroke is a number from the keypad.
if (e.KeyCode < Keys.NumPad0 || e.KeyCode > Keys.NumPad9)
{
// Determine whether the keystroke is a backspace.
if(e.KeyCode != Keys.Back && e.KeyCode != Keys.Decimal)
{
// A non-numerical keystroke was pressed.
// Set the flag to true.
nonNumberEntered = true;
}
}
}