Last active
August 29, 2015 14:10
-
-
Save arslanbilal/86503e62f4f0590d0318 to your computer and use it in GitHub Desktop.
Entering only letters and just one " " character into the textBox in C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void textBoxKeyPressLetter(object sender, KeyPressEventArgs e) | |
{ | |
if (!char.IsControl(e.KeyChar) && !char.IsLetter(e.KeyChar) && | |
(e.KeyChar != '.')) | |
{ | |
e.Handled = true; | |
} | |
// only allow one decimal point | |
if ((e.KeyChar == '.') && ((sender as TextBox).Text.IndexOf('.') > -1)) | |
{ | |
e.Handled = true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment