Possible Duplicate:
Restrict numbers and letters in textbox - C#
I have a textbox called TextBox1
. The user should only be allowed to enter capital letters. Other characters have to be denied. How can I do that?
private void TextBox1_KeyDown(object sender, KeyEventArgs e)
{
if (!"ABCDEFGHIJKLMNOPQRSTUVWXYZ".Contains(Convert.ToChar(e.KeyValue)))
{
SendKeys.Send(Convert.ToChar(0).ToString());
}
}