I have a form containing a tabcontrol that I want to modify based on user input on a previous form. I have created a tabcontrol named "TabControl" (creative, I know), and am attempting to add a tab for each value of the array "tabNames()". When I debug the program, I enter the values into the array on the first form, and when the second form loads, I get nothing in my tabcontrol. Any thoughts?
Public Sub frmContent_Load(ByVal sender As Object, ByVal e As EventArgs)
lblTitle.Text = frmiFormCreator.txtTitle.Text
For i As Integer = 0 To frmiFormCreator.numberOfTabs
Dim tabPage(frmiFormCreator.numberOfTabs) As TabPage
tabPage(i).Text = frmiFormCreator.tabNames(i)
TabControl.TabPages.Add(tabPage(i))
Next
End Sub
Try creating the TabPage object:
For i As Integer = 0 To frmiFormCreator.numberOfTabs
Dim newPage As New TabPage()
newPage.Text = frmiFormCreator.tabNames(i)
TabControl.TabPages.Add(newPage)
Next
Also, your code looks like it might be creating an extra tab. Maybe you want this:
For i As Integer = 0 To frmiFormCreator.numberOfTabs - 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With