开发者

Form loses focus and rocker switch key down event handler when clicking on a text box

Environment

  • Windows XP x32 Visual Studio 2005 Standard Edition
  • Honeywell Dolphin 9500 running Windows Mobile 2003 (Pocket PC 2003)
  • .NET Compact Framework 1.0 SP3 and .NET Framework 1.1
  • Using VC#

Goal

I have a form with a bunch of labels and text boxes on it. This form is populated by "Work Order" objects and is repopulated with the next or previous "Work Order" when the left or right hardware rocker buttons are pressed on the device. I want to allow the user to edit a combo/text box and then put focus back on the form so the the form's KeyDown event handler takes precedence.


Problem

On initial application load, when the form has focus, the rocker switch functions perfectly and the user can index back and forth through the work orders by hitting the hardware left or right buttons. When the user selects a text/combo box to edit the value, the form loses focus and the combo/text box's KeyDown event takes precedence.


Question

How can I force the controls to return focus to the form object without inhibiting a user's ability to edit the values?


Things I Have Tried

  • I tried setting up each control with a LostFocus() event handler that only contained the line: this.Focus() in order to return focus to the form once the current control lost focus. However, I "clicked" around and couldn't get the control to lose focus.

Code

In my past questions I have always put the code in a friendpaste.com document because the auto-generated form code makes the document somewhat lengthy. If the code needs to be in the body, just let me know and I will paste it here. Otherwise, the code is located at the friend paste link below.

http://friendpaste.com/CJ8CblLebHRXqA7开发者_StackOverflowUMLyvc


Also...

Feel free to critique any code you see for any reason but ideally do it as a comment to the question as opposed to an answer to keep the thread on topic. I am a new programmer and I am very new to Pocket PC Visual C# development and welcome, no plead for, any feedback/criticism I can get a hold of.

Additionally, let me know if further information is required and I will do my best to include it as soon as possible.

Thanks!


Override the ProcessCmdKey() method or set the form's KeyPreview property to true.


I just switched to a "moded" editing design and returned focus when "done editing".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜