<small id='LCTik'></small><noframes id='LCTik'>

    <legend id='LCTik'><style id='LCTik'><dir id='LCTik'><q id='LCTik'></q></dir></style></legend>
    • <bdo id='LCTik'></bdo><ul id='LCTik'></ul>
    <i id='LCTik'><tr id='LCTik'><dt id='LCTik'><q id='LCTik'><span id='LCTik'><b id='LCTik'><form id='LCTik'><ins id='LCTik'></ins><ul id='LCTik'></ul><sub id='LCTik'></sub></form><legend id='LCTik'></legend><bdo id='LCTik'><pre id='LCTik'><center id='LCTik'></center></pre></bdo></b><th id='LCTik'></th></span></q></dt></tr></i><div id='LCTik'><tfoot id='LCTik'></tfoot><dl id='LCTik'><fieldset id='LCTik'></fieldset></dl></div>

  • <tfoot id='LCTik'></tfoot>

        C# .NET Compact Framework,自定义 UserControl,焦点问题

        时间:2023-06-05

            <small id='z6ErO'></small><noframes id='z6ErO'>

              <tbody id='z6ErO'></tbody>
          1. <legend id='z6ErO'><style id='z6ErO'><dir id='z6ErO'><q id='z6ErO'></q></dir></style></legend>
            <i id='z6ErO'><tr id='z6ErO'><dt id='z6ErO'><q id='z6ErO'><span id='z6ErO'><b id='z6ErO'><form id='z6ErO'><ins id='z6ErO'></ins><ul id='z6ErO'></ul><sub id='z6ErO'></sub></form><legend id='z6ErO'></legend><bdo id='z6ErO'><pre id='z6ErO'><center id='z6ErO'></center></pre></bdo></b><th id='z6ErO'></th></span></q></dt></tr></i><div id='z6ErO'><tfoot id='z6ErO'></tfoot><dl id='z6ErO'><fieldset id='z6ErO'></fieldset></dl></div>
            <tfoot id='z6ErO'></tfoot>
                <bdo id='z6ErO'></bdo><ul id='z6ErO'></ul>
                1. 本文介绍了C# .NET Compact Framework,自定义 UserControl,焦点问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我有一个自定义 UserControl(一个标签和一个文本框).

                  I have a custom UserControl (a label and a textbox).

                  我的问题是我需要处理按键按下、按键向上事件以在表单中的控件之间导航 (.NET Compact Framework 文本框、组合框等).使用 .NET Compact Framework 框架提供的控件,它可以工作,但是当我到达我编写的用户控件时,该控件没有获得焦点(里面的文本框获得焦点)所以从这个用户控件我无法导航,因为在面板中我无法控制谁拥有焦点.

                  My problem is I need to handle the key down, key up events to navigate between controls in the form (.NET Compact Framework textbox, combobox, etc). With the controls provided by the .NET Compact Framework framework it works, but when I reach a usercontrol written by me, that control don`t get focus (the textbox inside get the focus) so from this usercontrol I cannot navigate because in the panel I don't have any control of who have focus.

                  一个小模型:Form->Panel->controls-> on keydown event (使用 KeyPreview) with a foreach 我检查面板上有焦点的控件并使用 SelectNextControl 传递给下一个控件,但没有人有焦点,因为 usercontrol 没有获得焦点...

                  A little mock up : Form->Panel->controls -> on keydown event (using KeyPreview) with a foreach I check what control have focus on the panel and pass to the next control with SelectNextControl, but no one have focus because the usercontrol don`t got focus...

                  我试图处理文本框 gotFocus 事件并将焦点放在用户控件上,但我得到了一个无限循环..

                  I tried to handle the textbox gotFocus event and put focus to the user control, but I got an infinite loop..

                  有人知道我能做什么吗?

                  Does somebody have any idea what can I do?

                  推荐答案

                  我们在 Compact Framework 上做了完全相同的事情,添加了一个全局焦点管理器,支持使用键盘输入在控件之间导航.

                  We've done the exact same thing on Compact Framework, adding a global focus manager that supports navigating between controls using keyboard input.

                  基本上,您需要做的是向下递归控件树,直到找到具有焦点的控件.它的效率不是很高,但只要每个关键事件只执行一次,这应该不是问题.

                  Basically, what you need to do is to recurse down the tree of controls until you find a control that has focus. It's not terribly efficient, but as long as you only do it once per key event, it shouldn't be an issue.

                  为我们的递归焦点查找函数添加了代码:

                  Added the code for our recursive focus finding function:

                  public static Control FindFocusedControl(Control container)
                  {
                      foreach (Control childControl in container.Controls) {
                          if (childControl.Focused) {
                              return childControl;
                          }
                      }
                  
                      foreach (Control childControl in container.Controls) {
                          Control maybeFocusedControl = FindFocusedControl(childControl);
                          if (maybeFocusedControl != null) {
                              return maybeFocusedControl;
                          }
                      }
                  
                      return null; // Couldn't find any, darn!
                  }
                  

                  这篇关于C# .NET Compact Framework,自定义 UserControl,焦点问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:作为 ColdFusion 开发人员,您应该如何学习 ASP.NE 下一篇:Web 服务需要一个 DataSet 对象,我如何通过 ColdF

                  相关文章

                  最新文章

                2. <tfoot id='xlmug'></tfoot>

                      <bdo id='xlmug'></bdo><ul id='xlmug'></ul>
                      <legend id='xlmug'><style id='xlmug'><dir id='xlmug'><q id='xlmug'></q></dir></style></legend>

                      <small id='xlmug'></small><noframes id='xlmug'>

                    1. <i id='xlmug'><tr id='xlmug'><dt id='xlmug'><q id='xlmug'><span id='xlmug'><b id='xlmug'><form id='xlmug'><ins id='xlmug'></ins><ul id='xlmug'></ul><sub id='xlmug'></sub></form><legend id='xlmug'></legend><bdo id='xlmug'><pre id='xlmug'><center id='xlmug'></center></pre></bdo></b><th id='xlmug'></th></span></q></dt></tr></i><div id='xlmug'><tfoot id='xlmug'></tfoot><dl id='xlmug'><fieldset id='xlmug'></fieldset></dl></div>