简体   繁体   English

vb.net中的TabControl快捷键

[英]TabControl shortcut key in vb.net

I have a tab control on my form.我的表单上有一个选项卡控件。 I would like to add a shortcut key for each page, so it could be used without a mouse or multiple tab key presses.我想为每个页面添加一个快捷键,这样就可以在没有鼠标或多个 Tab 键的情况下使用它。

I can't find any property in controltabs properties to do this.我在 controltabs 属性中找不到任何属性来执行此操作。 I have tried to use the &-sign in the Text property of tabPage, but it doesn't work.我曾尝试在 tabPage 的 Text 属性中使用 & 符号,但它不起作用。

You can use tabControl1.SelectTab(i) in the KeyDown event of the TabControl to move from one page to another.您可以在TabControlKeyDown事件中使用tabControl1.SelectTab(i)从一个页面移动到另一个页面。 I'm not sure how to get an underscore in the tabpage label.我不确定如何在标签页标签中获得下划线。

You can also use a command box on each tab page to go from one page to the next.您还可以使用每个标签页上的命令框从一页转到下一页。

Add code like this to your Form, then modify accordingly:将这样的代码添加到您的表单中,然后进行相应的修改:

Public Class Form1

    Protected Overrides Function ProcessCmdKey(ByRef msg As Message, keyData As Keys) As Boolean
        Select Case keyData
            Case Keys.F1
                TabControl1.SelectedIndex = 0
                Return True
            Case Keys.F2
                TabControl1.SelectedIndex = 1
                Return True
            Case Keys.F3
                TabControl1.SelectedIndex = 2
                Return True
        End Select

        Return MyBase.ProcessCmdKey(msg, keyData)
    End Function

End Class

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

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