How to Restrict Input Text to Characters in a Text Box

Use the KeyPress event to check for the keys pressed. See below for an example:

private void textFirstName_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) {    if ( !( char.IsLetter(e.KeyChar) ) )    {       e.Handled = true;    } }
Share the Post:
Share on facebook
Share on twitter
Share on linkedin


Recent Articles: