System.Windows.Forms.KeyPressEventArgs' does not contain a definition for 'KeyCode'  
Author Message
Redlightpacket





PostPosted: Common Language Runtime, System.Windows.Forms.KeyPressEventArgs' does not contain a definition for 'KeyCode' Top

Does any body know how to fix the problem above in the subject line. Any help would be nice on this issue. Thanks....

Here is my code that works with the keypress event.

What is the problem. Do I need to add some more code or what

private void textBox3_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)

{

if (e.KeyCode < Keys.D0 || e.KeyCode > Keys.D9)

{

TextBox3.Text = "_";

}

}




.NET Development22  
 
 
Mark Benningfield





PostPosted: Common Language Runtime, System.Windows.Forms.KeyPressEventArgs' does not contain a definition for 'KeyCode' Top

Hello All.

Redlightpacket:

Check the docs on the KeyPressEventArgs class. The property you are looking for here is .KeyChar, not KeyCode.

HTH.