.Net WinForms TabControl 窃取关注表单激活
我想知道是否有人可以帮助我?
我遇到的问题是 Windows 窗体 TabPage 窃取窗体重新激活的焦点。该窗体有一个带有四个或五个选项卡页的选项卡控件。每个选项卡页都有许多不同的控件。
场景如下: 用户通过第一个 TabPage 上的几个控件进行选项卡,然后生成并显示一个新表单(例如,来自 TextBox 的 Leave 事件之一),这会从第一个表单中删除焦点,因为它本身获得焦点。用户在新表单上选择一个值并将其关闭。 - 然后我希望原始表单知道用户已切换到的位置并将焦点设置到该控件。
但是,当表单重新激活时,它似乎将焦点设置为用户到达的位置,甚至不是活动 TabPage 的选项卡顺序中的第一个控件。相反,它将焦点放在活动 TabPage 本身上。
这附近有什么地方吗?
谢谢和亲切的问候, 杜安。
I wonder if there is anyone who can help me?
The issue I have is a windows form TabPage stealing focus upon form re-activation. The form has a TabControl with four or five TabPages. Each tab page has many various controls.
The scenario is as follows:
A user tabs through a few controls on the first TabPage and a new form is spawned and shown (say from one of the TextBox's Leave events) which removes focus from the first form as it takes focus itself. The users selects a value on the new form and closes it. - I would then expect the orginal form to know where the user had tabbed to and set focus to that control.
However, it seems when the form re-activates, it sets the focus, not back to where the user got to, or even the first control in the tab-order of the active TabPage. Instead it gives focus to the active TabPage itself.
Is there anywhere around this?
Thanks and kind regards,
Duane.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我创建了变量(在选项卡控件类中,以将它们保持在范围内)来存储当前页面和最后访问的页面,还创建了一个变量来存储具有焦点的控件,使用指针、引用等。
当您返回时,使用该变量将焦点恢复到该控件。
华泰
I have created variables (in the tab-control class, to keep them in scope) to store the current page and last page visited, also create a variable to store the control that had focus, use a pointer, reference, whatever.
When you go back, use the variable to restore focus to that control.
HTH