Catching key events to a panel?
-
Hello, I'm writing a small application in which a draw onto a panel and want to control the painting on the panel with the arrow keys (think of it as a painting program with the keys instead of mouse if you wish..) Now the thing is, from what I figure the Panel can't gain keyboard focus. So I would need some other way to retrieve the key events. What do I do? Place a dummy control somewher, hide it, give it keyb. focus and then reacts on the events from there? A better solution? If so please tell me the 'right' way to do it.. /Bjorn
-
Hello, I'm writing a small application in which a draw onto a panel and want to control the painting on the panel with the arrow keys (think of it as a painting program with the keys instead of mouse if you wish..) Now the thing is, from what I figure the Panel can't gain keyboard focus. So I would need some other way to retrieve the key events. What do I do? Place a dummy control somewher, hide it, give it keyb. focus and then reacts on the events from there? A better solution? If so please tell me the 'right' way to do it.. /Bjorn
Is it possible for you to use a UserControl rather than a panel? That would solve your keyboard input problem. Karl Baum CEO of KGB Technologies Specializing in custom software development.
-
Is it possible for you to use a UserControl rather than a panel? That would solve your keyboard input problem. Karl Baum CEO of KGB Technologies Specializing in custom software development.
Yes it's most certainly possible, thanks for the suggestion. But just out of interest, would there be a way to do it even with a panel control? And if so, how?
-
Yes it's most certainly possible, thanks for the suggestion. But just out of interest, would there be a way to do it even with a panel control? And if so, how?
The only thing I can think of is to have the form that the panel is on receive the keyboard events. Then it could call functions that cause your panel to do appropriate things. Karl Baum CEO of KGB Technologies Specializing in custom software development.