Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted
Try setting the KeyPreview property of the form to true. This registers the key events of each control to the forms key events.
Anybody looking for a graduate programmer (Midlands, England)?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...