将标签页保存到设置vb

时间:2015-02-10 20:30:26

标签: vb.net tabs settings

我尝试在关闭应用/表单时保存活动标签页,并在下次启动时再次显示该标签,而不是第一个。尝试使用设置,使用下面的(简化)方法:

Public Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
Me.TabControl1.SelectedTab = My.Settings._frmTab
end sub

' Stuff

Public Sub Form1_Close(sender As Object, e As System.EventArgs) Handles Me.FormClosing
My.Settings._frmTab = Me.TabControl1.SelectedTab
End Sub

在设置中输入设置为:System.Windows.Forms.TabPage

没有快乐。似乎适用于其他类型,如System.Drawing等...

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

只需将TabControl的选定索引保存为整数。

Private Sub Main_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
    tabControlMain.SelectedIndex = My.Settings.SelectedTab
End Sub

Private Sub Main_FormClosing(sender As System.Object, e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
    My.Settings.SelectedTab = tabControlMain.SelectedIndex
End Sub