You can dynamically remove and inseret TabPages into the TabControl.TabPages collection to hide and show tabs at runtime.
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);
}
}
Share with