Listening to program events.
-
How do I listen for program events? At the moment when listening for key presses, it only works on user controls that have the keypress event set up. How can I get the program to listen to the keypress event that occus in all of a single forms child controls. E.g. so if the form has 5 different user controls, is there a way to set up the even in the form so that if the key is pressed while any of the child controls have focus, the event in the main form is still called? - Munty
-
How do I listen for program events? At the moment when listening for key presses, it only works on user controls that have the keypress event set up. How can I get the program to listen to the keypress event that occus in all of a single forms child controls. E.g. so if the form has 5 different user controls, is there a way to set up the even in the form so that if the key is pressed while any of the child controls have focus, the event in the main form is still called? - Munty
Assign all of the child controls keypress events to the forms keypress event handler. Note that this would not actually raise the forms event. If you needed that you may be able to call the forms keypress event (using the RaiseEvent statement) from the event handlers of each of the controls.
topcoderjax - Remember, Google is your friend.
-
Assign all of the child controls keypress events to the forms keypress event handler. Note that this would not actually raise the forms event. If you needed that you may be able to call the forms keypress event (using the RaiseEvent statement) from the event handlers of each of the controls.
topcoderjax - Remember, Google is your friend.
The problem with that, is that the KeyPress events don't seem to work on the User controls that edit their Graphics. (Button Click events do, but I need keypress events.) That's why I was hoping there's some way of making shortcut keys from the parent form. - Munty
-
How do I listen for program events? At the moment when listening for key presses, it only works on user controls that have the keypress event set up. How can I get the program to listen to the keypress event that occus in all of a single forms child controls. E.g. so if the form has 5 different user controls, is there a way to set up the even in the form so that if the key is pressed while any of the child controls have focus, the event in the main form is still called? - Munty
Enable the KeyPreview property on the form, then handle the forms KeyDown/KeyPress/KeyUp events. The form will get first look at the key events before they're sent to the child controls.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
Enable the KeyPreview property on the form, then handle the forms KeyDown/KeyPress/KeyUp events. The form will get first look at the key events before they're sent to the child controls.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007