如何 Select 选项卡

How to Select Tab

我有 TabControl 和 4 个 TabPages。我需要以编程方式 select 第二个选项卡!

您有两种方法可以做到

  1. 选定选项卡:

    MyTabControl.SelectedTab = MyTabPage(你要select的TabPage)

  2. SelectedIndex:

    MyTabControl.SelectedIndex = 1(1是第二个TabPage的索引)

这是我的方法,我相信有人会觉得有用,使用 My.Settings:

退出代码 button/routine:

    Private Sub PicClose_App_Click(sender As Object, e As EventArgs) Handles PicClose_App.Click

    ' Save the current active tab index, this will be used on next startup to determine on which TabPage to start
    My.Settings.Main_Form_Startup_TabPage = MyTabControl.SelectedTab.TabIndex

    Application.Exit()
End Sub

从主窗体的Load事件中调用的代码:

    Public Sub Form_Startup_TabPage()
    ' Get tab index from settings, 0 has been set as default
    Dim IntStartup_TabPage As Integer = My.Settings.Main_Form_Startup_TabPage

    ' Select the last tab used
    FrmMain.TabChar_Group_Selection.SelectedIndex = IntStartup_TabPage

End Sub