简体   繁体   English

专注于工具条按钮vb.net

[英]Focus on toolstrip button vb.net

I created a toolstrip with some buttons. 我用一些按钮创建了一个工具条。 I have a form with some objects (like textbox,checkbox,button etc.) and when i get the focus on last item,when i finish to compile i need with tab on keyboard to get focus on save button on the toolstrip. 我有一个带有一些对象的表单(如文本框,复选框,按钮等),当我把注意力集中在最后一项时,当我完成编译时,我需要使用键盘上的选项卡来关注工具条上的保存按钮。

Can anyone tell me how to do that? 谁能告诉我怎么做? Because there isn't the focus option on toolstrip. 因为工具栏上没有焦点选项。

Thanks. 谢谢。

You'll need to override the Tab key handling. 您需要覆盖Tab键处理。 Say your last control is Button3 and the toolstrip button is SaveButton then the code looks like this: 假设您的最后一个控件是Button3,而工具条按钮是SaveButton,那么代码如下所示:

Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean
    If keyData = Keys.Tab AndAlso Me.ActiveControl Is Button3 Then
        ToolStrip1.Focus()
        SaveButton.Select()
        Return True
    End If
    Return MyBase.ProcessCmdKey(msg, keyData)
End Function

Adjust as necessary to work with your specific controls. 根据需要进行调整以使用特定控件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM