MS Access 选项卡控制:焦点错误
我有一个具有不同页面的选项卡控件。当使用此选项卡控件启动表单时,选项卡会丢失,并且内页会获得所有屏幕焦点。选项卡控件用于导航,因此用户会迷失方向。
有没有什么方法可以让选项卡在屏幕上可见,而无需将屏幕调整得更小?
期望结果:
+--------------------+
| Tab1 | Tab2 | Tab3 |
+--------------------+
| Name: ______ |
实际屏幕:
^
+--------------------+ |_|
| Name: ______ | | |
I have a tab control with different pages. When starting up the form with this tab control the tabs get lost and the inner page gets all the screen focus. The tab control is used for navigation so the user will get lost this way.
Is there any way to let the tabs be visible on the screen without just resizing the screen to be smaller?
Desired result:
+--------------------+
| Tab1 | Tab2 | Tab3 |
+--------------------+
| Name: ______ |
Actual screen:
^
+--------------------+ |_|
| Name: ______ | | |
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
减小选项卡控件的大小是可行的(正如您自己发现的那样),但是还有一种替代解决方法:
OnOpen
或OnLoad
事件中,调用.SetFocus命令按钮上的
方法SendKeys
(我知道,我知道...)切换到选项卡控件示例代码:
上述步骤的说明:
杂项注释:应提问者的要求,我在答案中添加了一些评论:
对于那些将来可能找到此答案的人,请注意,仅当您需要选项卡控件接收键盘焦点时才需要执行上述步骤 5(这是原始提问者的关键要求)。如果你可以没有它生活,我建议你这样做。
更新:正如 David Fenton 在评论中指出的那样,您可以使用
Ctl
+Tab
/Ctl
+Shift
+Tab
在选项卡之间来回移动。这与大多数选项卡式界面(例如浏览器)一致,并且无需使用SendKeys
。Reducing the size of the tab control works (as you discovered yourself), however there is an alternative workaround:
OnOpen
orOnLoad
event, call the.SetFocus
method on the command buttonSendKeys
(I know, I know...) to tab to the Tab ControlSample code:
Explanation of the above steps:
Miscellaneous Notes: At the asker's request I am including a couple of comments as part of the answer itself:
For those who may find this answer in the future, please take note that Step 5 above is only necessary if you need the tab control to receive keyboard focus (a critical requirement for the original asker). If you can live without it, I would suggest that you do.
UPDATE: As David Fenton points out in the comments, you can use
Ctl
+Tab
/Ctl
+Shift
+Tab
to move back and forth between the tabs. This is consistent with most tabbed interfaces (eg, browsers) and eliminates the need to useSendKeys
.嗯,我知道我只使用过 Tab 控件一两次 - 但在执行/加载表单时它在表单上显示时从未遇到过问题。当然,除了表单的“详细信息”部分之外,我从未在任何地方使用过它,但我会说检查一下这头野兽是否以某种方式将其“启用”或“可见”属性(如果适用)设置为“否”。当然,我可能是错的——这种情况确实发生了,当它发生时我渴望学习新的东西。 :)
Hmmm, I know I've only played with the Tab control once or twice - but never had a problem with it showing up on the form when the form is executed/loaded. Granted, I've never had it in any place except the Detail section of the form, but I'd say check to see if the beast has somehow gotten it's Enabled or Visible property (if applicable) set to No. Of course, I could be wrong - it happens, and I am eager to learn something new when it happens. :)
我不知道我是否理解这个问题,但在评论中,您说 Access 不允许您将焦点设置到选项卡控件,但您可以将焦点设置到选项卡页:
...其中 N 是您想要将焦点设置到的选项卡页的索引),或 with:
这两者都可以将焦点设置到选项卡页。
您说您想将焦点设置到选项卡控件,但我不明白您为什么要这样做。选项卡控件本身没有可以获得焦点的元素——只有其 Pages 集合的成员可以获得焦点。
我再次建议您由于某些其他原因而将自己逼入绝境,并且没有解决办法。因此,你必须弄清楚如何避免陷入这个无法解决的问题。我只是不太理解您对问题的解释,无法提供解决方案,但我怀疑没有办法通过不同的方法来解决问题。
I don't know that I understand the question, but in a comment, you say that Access doesn't allow you to set focus to a tab control, but you can set focus to the tab page:
...where N is the index of the tab page you want to set focus to), or with:
Both of these work to set focus to the tab page.
You say you want to set focus to the tab control, but I can't figure out why you'd want to do that. The tab control itself has no elements that can get focus -- only the members of its Pages collection do.
Again, I would suggest that you've painted yourself into a corner for some other reason and there's no solution. Therefore, you have to figure out how to avoid getting into that insoluble problem. I simply don't understand your explanation of the problem well enough to be able to offer a solution, but I doubt there's no way to resolve the issue through a different approach.