HSN Posted December 6, 2005 Posted December 6, 2005 Hello, I'm developing a dialog based C# 2.0 application. My dialog has some buttons on it. I need to handle some "keyPress" events on my dialog such that each time for example key 1 was pressed, a certain action is taken. But, when I defined the event handler I found it not wokring. The problem was that the focus is on buttons not on the dialog and the handler belongs to my dialog. To solve the problem I used: this.Focus(); But didn't work! How can keep the focus always on my dialog such that I can handle the key event. Or is there any other solution that lets me use the key handler? Thx Quote
Cags Posted December 6, 2005 Posted December 6, 2005 Try setting the KeyPreview property of the form to true. This registers the key events of each control to the forms key events. Quote Anybody looking for a graduate programmer (Midlands, England)?
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.