Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hiding tabPages within a tabControl component

Status
Not open for further replies.

StevenK

Programmer
Jan 5, 2001
1,294
0
0
GB
How do I go about the hiding of a certain tabPage within a tabControl component ?
I'm able to remove the tabPage within the tabControl by using the syntax :
tabControl1.TabPages.Remove(tabPage2);
and then able to re-add it using the syntax :
tabControl1.TabPages.Add(tabPage2);
However when it's re-added the tabPage is added in the last place (at the end of the pages already present).

How else can I do this ?
Thanks in advance
Steve
 
The Tab control shows u the Tab pages, because they are part of the collection.

What u need to do is Clear off the collection first, and depending on the user selection add them back to the collection.

ex:

If u have a tabcontrol, say tabControl1, all the tab pages have been created at design time. say tbPage1, tbpage2 ... tbPage9

in ur combobox change event ->

1) this.tabControl1.Controls.Clear()

2) depending on what tab pages u want to show ( say 1 , 4 , 7 )

this.tabControl1.Controls.AddRange(new System.Windows.Forms.Control[]
{ this.tbPage1, this.tbPage4,
this.tbPage7
});

Lemme know if that worked
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top