Aenu
Aenu

Reputation: 1

How to make array of textboxes accept only specific alphabets?

i am using visual studio c#.net winform and i have 2d array of 81 textboxes. . . i can't figured out how it is possible to make these textboxes accept only specific alphabet. . . can any one please show me the code. . . THanx in advance

Upvotes: 0

Views: 696

Answers (1)

Akram Shahda
Akram Shahda

Reputation: 14781

private void textBox_KeyPress(object sender, KeyPressEventArgs e)
{
    List<char> chrs = new List<char>{'1', '2', '3'};
    if (!chrs.Contains(e.KeyChar))
    {
        e.Handled = true;
    }
}

Upvotes: 2

Related Questions