|
-
October 30th, 2010, 03:08 AM
#1
KeyPress Event Issue
Can anyone tell me ???Why KeyPress Event is Not working .when I press enter .It Does not go in the KeyDown event(Where i did breakpoint) during debugging.let me know the idea. Any help would be highly appreciated !!!
Code:
private void TxtPumpNo1A_Keydown(object sender, System.Windows.Forms.KeyEventArgs e){
if (e.KeyCode == Keys.Return){
double val = 0;
try{
val = double.Parse(TxtPumpNo1A.Text);
}
catch{
MessageBox.Show("PumpNo1A Cannot be Text");
TxtPumpNo1A.Text=string.Empty;
TxtPumpNo1A.Focus();
}
-
October 30th, 2010, 02:48 PM
#2
Re: KeyPress Event Issue
Of course we can't tell you because you have not given us a complete code sample. Where is that method assigned to the KeyDown event of your textbox. The fact that the "d" in your method signature is lowercase indicates that the event was not generated automatically by the IDE (either in the code window or through the Properties window).
-
October 31st, 2010, 02:18 PM
#3
Re: KeyPress Event Issue
void button1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if (e.KeyChar.Equals((char)13)) //(char)13 = "Retrun/Enter" on English Standard keyboards
{
//do something;
}
}
-
October 31st, 2010, 02:48 PM
#4
Re: KeyPress Event Issue
Good call crash, but you can just use Keys.Enter.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|