在选项卡控件上创建一个按钮,以便您可以点击空格键 [英] Make a button on a tab control focused so you can hit the Space Bar

查看:83
本文介绍了在选项卡控件上创建一个按钮,以便您可以点击空格键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将焦点设置在我的标签控件的第1页上的按钮上。看起来我在设置焦点方面取得了成功,因为我看到按钮上的突出显示,但是当我按下空格键时,我得到了主窗体的子菜单;按钮没有按下。我注意到当我单击选项卡控件时,突出显示的按钮会显示添加的突出显示。它看起来像原始高光上的虚线。如果在出现此额外突出显示后按空格键,按钮将正确按下。这是我现在使用的代码将焦点设置到选项卡控件上的按钮...


Me!tabAllTabs.Pages(0).Controls!cmdAddNote.SetFocu s


如何在不点击选项卡控件的情况下将该按钮设置为只需按空格键即可按下该按钮?

......这个附加状态叫什么?我认为一旦你把焦点放在一个按钮上,你只需按空格键或输入即可。


谢谢,

Adam

解决方案

选项卡上的控件与主窗体上的控件的引用方式相同。您应该能够使用主表单代码:

展开 | 选择 | Wrap | 行号


我刚刚对此做了一些研究,以及我学到了什么有点有趣。


首先,我可以说我从未见过有人通过页面的控件集合引用选项卡控件页面上的控件。我甚至都想不到它。


看来,当通过所描述的路线引用控件时,控件在页面获得焦点之前不会获得焦点,由于调用引用的方式。当你专注于一种形式的控制,然后打开另一种形式时,就有点像。当第二个表单打开时,仍然会选中具有旧表单焦点的控件,但除非该表单成为活动表单,否则它实际上不会获得焦点。


因此,通过在该方法中引用它,您实际上已经选择了它,但是无法给它实际的焦点。除非页面被给予焦点。如果直接通过激活且具有焦点的表单设置控件的焦点,则立即将焦点放在该控件上。


ChipR,Topher23,

谢谢你们的回复。


ChipR,我最初尝试了你的建议并获得了相同的结果;按钮被选中但仍然没有响应空格键作为推动。


Topher,

你对它如何工作的描述听起来对我来说是正确的但是我仍然无法让它工作。


我试过这个......

展开 | 选择 | Wrap | 行号

I am trying to set the focus on a button that sits on page 1 of my tab control. It looks like I''m successful at setting the focus because I see the highlight on the button, but when I push the space-bar, I get the sub menu for the main form; the button does not press down. I notice that when I click on the tab control, the highlighted button takes on an "added highlight". It looks like a dotted line over the original highlight. If I press the space-bar after this additional highlight appears, the button presses properly. Here is the code I''m using now to set the focus to the button on the tab control...

Me!tabAllTabs.Pages(0).Controls!cmdAddNote.SetFocu s

How do I get that button to the point that I only need to hit the space-bar to press it, without clicking on the tab control?

... and what is this additional state called? I thought that once you set the focus on a button, you needed only press space or enter to engage it.

Thanks,
Adam

解决方案

Controls on tabs are referred to the same way as controls on the main form. You should be able to use from main form code:

Expand|Select|Wrap|Line Numbers


I just did some research on this, and what I learned is kind of interesting.

First off, though, may I say I''d never seen anyone refer to a control on a tab control page through the controls collection of the page. I would never have even thought of it.

It appears that, when referencing the control through the route described, the control doesn''t receive the focus until the page receives the focus, due to the way the reference is called. It''s sort of like when you have focus on a control in one form, then open another form. When the second form opens, the control that had the focus in the old form is still selected, but it won''t actually get the focus unless that form becomes the active form.

So, by referencing it in that method, you''ve in essence selected it, but are unable to give it the actual "focus" unless the page is given focus. If you set the focus for the control directly through the form, which is active and has focus, then focus is on that control immediately.


ChipR, Topher23,

Thank you both for the response.

ChipR, I originally tried what you suggested and got the same result; the button was selected but still did not respond to the space-bar as a push.

Topher,
Your description of how it works sounds right to me, but I still can''t get it to work.

I''ve tried this...

Expand|Select|Wrap|Line Numbers


这篇关于在选项卡控件上创建一个按钮,以便您可以点击空格键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆