Hi,
Am new here and also a beginner in VB. I have created a form with a TabControl and when I click the tab page it creates another TabControl Dynamically. This works fine.
I would like to save the form with the newly created TabControl and when I close the form and reload it the new TabControl should still be there.
Is there a way of doing this?
I have tried saving using my.settings but it doesn't work. Any help would be very much appreciated.
Here's the code:
Am new here and also a beginner in VB. I have created a form with a TabControl and when I click the tab page it creates another TabControl Dynamically. This works fine.
I would like to save the form with the newly created TabControl and when I close the form and reload it the new TabControl should still be there.
Is there a way of doing this?
I have tried saving using my.settings but it doesn't work. Any help would be very much appreciated.
Here's the code:
VB.NET:
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Form1_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
Me.BackColor = My.Settings.MyBackColor
End Sub
'CREATE A NEW TAB CONTROL AT RUNTIME
Private Sub TabPage1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabPage1.Click
' Create a TabControl and set its properties
Dim dynamicTabControl As New TabControl()
Dim TabPage As New TabPage()
dynamicTabControl.Name = "DynamicTabControl"
dynamicTabControl.BackColor = Color.White
dynamicTabControl.ForeColor = Color.Black
dynamicTabControl.Font = New Font("Georgia", 16)
dynamicTabControl.Width = 300
dynamicTabControl.Height = 200
'Add TabPage
TabPage.Name = "tabPage2"
TabPage.Text = "Author"
TabPage.BackColor = Color.Green
TabPage.ForeColor = Color.White
TabPage.Font = New Font("Verdana", 12)
TabPage.Width = 100
TabPage.Height = 100
dynamicTabControl.TabPages.Add(TabPage)
Me.Controls.Add(dynamicTabControl)
My.Settings.MyTAB = dynamicTabControl
My.Settings.Save()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ColorDialog1.ShowDialog()
My.Settings.MyBackColor = ColorDialog1.Color
End Sub
End Class
Last edited: