How can I capture and prevent user from enter special charaters like *, @, and comma in KeyDown event?
What I have below is not working currently. It doesn't capture the '*' char. Also, how can I capture comma(,) and period(.)? Thank you.
private void txtContextName_KeyDown(object sender, KeyEventArgs e)
if (e.KeyCode == Keys.Decimal || e.KeyCode == (Keys.Shift & Keys.D8) ||
e.KeyCode == (Keys.Shift & Keys.D1))
e.Handled = true;
//e.KeyCode == Keys. '@', '.', ',', '!','*' }