Problem Adding and Removing Tabs with the Windows Forms TabControl

  • Thread starter Thread starter MosheS Singer
  • Start date Start date
M

MosheS Singer

Guest
I have 13 tabs in my Main Form. All the tabs have many fields where user enters the data. In the first tab, there are different selections. Each selection opens different other tabs. For ex. Selection 1 opens Tab # 1) 2) 8) 11) and 12), and all the other tabs are supposed to become invisible.

I tried using the following code to accomplish the above,

Me.SSTab1.TabPages.Add(SSTab1_TabPage1)
Me.SSTab1.TabPages.Add(SSTab1_TabPage2)
Me.SSTab1.TabPages.Add(SSTab1_TabPage8)
Me.SSTab1.TabPages.Add(SSTab1_TabPage10)
Me.SSTab1.TabPages.Add(SSTab1_TabPage11)

Me.SSTab1.TabPages.Remove(SSTab1_TabPage3)
Me.SSTab1.TabPages.Remove(SSTab1_TabPage9)
Me.SSTab1.TabPages.Remove(SSTab1_TabPage6)
Me.SSTab1.TabPages.Remove(SSTab1_TabPage5)
Me.SSTab1.TabPages.Remove(SSTab1_TabPage4)
Me.SSTab1.TabPages.Remove(SSTab1_TabPage7)
Me.SSTab1.TabPages.Remove(SSTab1_TabPage12)
Me.SSTab1.TabPages.Remove(SSTab1_TabPage13)
but what happened is that all tabs that were added by code, came in empty. Absolutely containing no fields or any data.

I need working code that will make visible the tabs, bringing in all the fields and data, and make the other tabs invisible, without losing any information.

You can be sure that I searched for sample code and solutions and I have not found any yet.

I tried making the tabs visible, but "invisible" does not work, so I tried using the code "Remove" but it didn't either work, because if I used Visible and Remove, for Tab 1,2, 8, 10, 11, then Tabs 1 and 2 displayed properly, but 8, 10, 11 were empty, since the tabs before these 3 were "Removed".

Please reply with working code. Thank You.

Continue reading...
 
Back
Top