Windows Develop Bookmark and Share   
 index > Windows Forms General > Form_KeyDown events are sometimes not firing
 

Form_KeyDown events are sometimes not firing

Hi,

I have a Win form that contains only one dynamicly created textbox control at any given time. I also use my form's KeyDown event and the textbox's KeyPress event to track and handle key trokes. In order for the form to pic up the key first, I set KeyPreview to true.

My problem is however, that the form's KeyDown event SOMETIMES doesn't fire (return key is the key I need and it is the key I used for my testing). The form KeyDown event will always fire if the textboxdoesnot present on the form. But when the textbox is created, it appears that the return key strokes sometimes get captured by the form's KeyDown event and sometimes don't.

What am I doing wrong here?

Thanks

Feng

Feng26  Friday, August 03, 2007 3:38 PM

Hi, Feng26,

It depends how you dynamically add your TextBox Control.

Some other controls, such as Buttons, may trap the Enter key when they are activated.

Please show us some codes if possible.

Regards.

Yu Guo â€?MSFT  Monday, August 06, 2007 6:27 AM
We are changing the issue type to “Comment�because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question�by editing your initial post and changing the radio button at the top of the post editor window. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.
Thank you!

Yu Guo â€?MSFT  Thursday, August 09, 2007 7:34 AM

Hi Yu,

The approach I was taking doesn't seem too promissing for me at the time being. That's why I am trying to take a different rout now, a work arround acctually. Please keep the type of the issue as "comment" and I will make sure to come back and share the info if I ever find a solution to my origional question.

Thank you so much for all your help!

Feng

Feng26  Thursday, August 09, 2007 1:42 PM

You can use google to search for other answers

Custom Search

More Threads

• Find intersection point?
• Difference between Sub Form_Load and Sub New
• SPI_SETWORKAREA
• Multiple DropDownList changes At a time when one dropdown chaged
• Strange behavior on button click
• How: Layout Managers in .Net like Java
• FolderBrowserDialog Bug. Dialog keeps crashing on x64 system
• A really basic question for Windows forms.
• change background at runtime
• Picturebox draw rectangle at the mouse position after scaling.