Hi,
Working in C# 2008. I have a TreeView and a TabControl on a split panel. I have 8 TabPages on the TabControl. I need to Hide/Show Tabs based on the the TreeView selection. However, using the tabControl1.tabPages[0].Hide(); seems to do nothing, for any of the tabPages. Any idea what I am missing? Is there another/better way to do this?
Thanks,
Bruce
Loading
Master BillaPosted Oct 12, 2009, 12:45 PM
You can do this way
TabPage tabPageSave = null;
private void button1_Click(object sender, EventArgs e)
{
//hide a tab by removing it from the TabPages collection
this.tabPageSave = tabControl1.SelectedTab;
this.tabControl1.TabPages.Remove(this.tabPageSave);
}
private void button2_Click(object sender, EventArgs e)
{
//show a tab by adding it to the TabPages collection
if (this.tabPageSave != null)
{
int loc = tabControl1.SelectedIndex;
this.tabControl1.TabPages.Insert(loc, this.tabPageSave);
}
}
Thank you
Jayhawks RockPosted Oct 12, 2009, 4:54 PM
Roei BarPosted Oct 12, 2009, 2:09 PM
TabPage tabPageSave = null;private void button1_Click(object sender, EventArgs e){//hide a tab by removing it from the TabPages collectionthis.tabPageSave = tabControl1.SelectedTab;this.tabControl1.TabPages.Remove(this.tabPageSave);}private void button2_Click(object sender, EventArgs e){//show a tab by adding it to the TabPages collectionif (this.tabPageSave != null){int loc = tabControl1.SelectedIndex;this.tabControl1.TabPages.Insert(loc, this.tabPageSave);}