In this post we will see how to convert textbox text to upper case when it is entered .
For this we will consider an example, suppose a textbox is taken for full name, then we should allow only characters/letters in it. And we want full name to be entered in upper case. For this we can validate a textbox such that the text entered in it should appear in uppercase automatically even if user entered a lowercase.
I am taking a textbox txtFullName on Form and a errorprovider. Now we are taking a keypress event of textbox txtFullName . The c# code is like this..
private void txtFullName_KeyPress(object sender, KeyPressEventArgs e)
if (!char.IsLetter(e.KeyChar) && Convert.ToInt32(e.KeyChar) != 8 && Convert.ToInt32(e.KeyChar) != 32)
errorProvider1.SetError(txtFullName, "Only letters allowed");
e.Handled = true;
e.KeyChar = char.ToUpper(e.KeyChar);
If any other key like number or special character is entered by the user , the error provider will blink.