Event issue
-
Hi If there is not any button control on winform then forms key press event is fires But if we place button control on winform then focus directly goes to button and keypress event of the form does not get fired.What can be the reason. It can be easily replicated by just writing any code in keypress event of windows form there should not be any control on the form then its keypress will be fired, now just place a button control u will see form's key pressed is not getting fired. It seems focus issue.Can anyone advice. Atul Kumar
-
Hi If there is not any button control on winform then forms key press event is fires But if we place button control on winform then focus directly goes to button and keypress event of the form does not get fired.What can be the reason. It can be easily replicated by just writing any code in keypress event of windows form there should not be any control on the form then its keypress will be fired, now just place a button control u will see form's key pressed is not getting fired. It seems focus issue.Can anyone advice. Atul Kumar
In Windows applications, if there is ANY control on a form that CAN receive the focus it does, and the form does not. You are correct, it is a focus issue, and it was designed that way. HTH explain it anyway. ;)
-
Hi If there is not any button control on winform then forms key press event is fires But if we place button control on winform then focus directly goes to button and keypress event of the form does not get fired.What can be the reason. It can be easily replicated by just writing any code in keypress event of windows form there should not be any control on the form then its keypress will be fired, now just place a button control u will see form's key pressed is not getting fired. It seems focus issue.Can anyone advice. Atul Kumar
Set the Form's KeyPreview property to true, and it's KeyPress event will fire before the active control's KeyPress. Josh
-
Set the Form's KeyPreview property to true, and it's KeyPress event will fire before the active control's KeyPress. Josh
Thanx a LOT Josh It is working.