Live Chat Icon For mobile
Live Chat Icon

How do I dynamically hide/unhide tabs in a TabControl?

Platform: WinForms| Category: TabControl

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;

        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

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.