Is this a bug in .NET 2.0?
-
I'm developing an windows application in .NET 2.0 where the user is supposed to navigate around the application using the arrow keys(I'm using KeyDown event to handle user key input). My problem is that I want to use UserControls in my application but whenever I add my UserControls to my windows form the form don't recieve any KeyDown events when I press the arrows keys, however it reacts to any other keys being pressed! Is this a bug and is there another way to do this? Thanks
Vester
-
I'm developing an windows application in .NET 2.0 where the user is supposed to navigate around the application using the arrow keys(I'm using KeyDown event to handle user key input). My problem is that I want to use UserControls in my application but whenever I add my UserControls to my windows form the form don't recieve any KeyDown events when I press the arrows keys, however it reacts to any other keys being pressed! Is this a bug and is there another way to do this? Thanks
Vester
-
I'm developing an windows application in .NET 2.0 where the user is supposed to navigate around the application using the arrow keys(I'm using KeyDown event to handle user key input). My problem is that I want to use UserControls in my application but whenever I add my UserControls to my windows form the form don't recieve any KeyDown events when I press the arrows keys, however it reacts to any other keys being pressed! Is this a bug and is there another way to do this? Thanks
Vester
adfgh75 wrote:
My problem is that I want to use UserControls in my application but whenever I add my UserControls to my windows form the form don't recieve any KeyDown events when I press the arrows keys, however it reacts to any other keys being pressed!
The key press is probably being handled by another control. Have you tried setting KeyPreview[^]to true
Michael CP Blog [^] Development Blog [^]
-
adfgh75 wrote:
My problem is that I want to use UserControls in my application but whenever I add my UserControls to my windows form the form don't recieve any KeyDown events when I press the arrows keys, however it reacts to any other keys being pressed!
The key press is probably being handled by another control. Have you tried setting KeyPreview[^]to true
Michael CP Blog [^] Development Blog [^]
Well yes, I have set KeyPreview to true on the form (and breakpoints to trace the event)and it still doesn't throw any KeyDown event when when I press the arrow keys, but it throws it when I press any other key. If I let the class inherit from Panel instead of UserControl or Control it works perfect. However I've discovered that if I override the ProcessCmdKey() function in the form and process the key pressed there instead it will work.
.NET