S
Scott
I'm new to see C#, and the Code below should force lowercase characters to
uppercase when the key is pressed from my understanding. However, when the
key is first pressed it shows nothing in the textbox, but if you press it a
second time it shows the key pressed in uppercase as it should be. What am
I doing wrong, and how can I fix it so it shows the key pressed in uppercase
as soon as the key is pressed?
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
{
//Force Upper-case Characters in textbox
txtYourFirstName.CharacterCasing=CharacterCasing.Upper;
}//End if-else
}//End private void txtYourFirstname_KeyPress
Thanks,
Scott
uppercase when the key is pressed from my understanding. However, when the
key is first pressed it shows nothing in the textbox, but if you press it a
second time it shows the key pressed in uppercase as it should be. What am
I doing wrong, and how can I fix it so it shows the key pressed in uppercase
as soon as the key is pressed?
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
{
//Force Upper-case Characters in textbox
txtYourFirstName.CharacterCasing=CharacterCasing.Upper;
}//End if-else
}//End private void txtYourFirstname_KeyPress
Thanks,
Scott