I have the snippet of code at the end of this message that has the following
line of code in it:
txtYourFirstname.SelectedText=Convert.ToString(Cha r.ToUpper(e.KeyChar));
The problem I am having is when it converts lowercase to upper case it also
leaves the lowercase character in the textbox. In other words, if you type
the letter 'q' in the textbox it will convert it to uppercase but show 'Qq'.
What am I doing wrong, and how can I correct it? Also, I'm just starting to
learn C#.
private void txtYourFirstname_KeyPress(object sender,
System.Windows.Forms.KeyPressEventArgs e)
{
//Validate for non-Character values
if(!Char.IsLetter(e.KeyChar) && !Char.IsControl(e.KeyChar))
{
e.Handled = true; //Remove/Prevent values from being entered if
non-Character
}
else
{
txtYourFirstname.SelectedText=Convert.ToString(Cha r.ToUpper(e.KeyChar));
}
}