• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1581
  • Last Modified:

tabcontrol in winforms

In winforms C# VS2005
I need an advise of UI:
I want to have a tabcontrol with 2 tabs but I don't want the first tab to be chosen by default.
I want at the beginning that everything will be empty and only on press the first tab to see its page.
HOw can I do it.
1 Solution
I have tried some things (setting SelectedTab = null or SelectedTabIndex = -1) but this woulnd work. The only way I see:
Remove all controls from the first tab at the constructor like
        Control[] mControls;

        public Form1()
            mControls = new Control[tabPage1.Controls.Count];

and add them again at the first MouseClick

private void tabControl1_MouseClick(object sender, MouseEventArgs e)
            if (tabPage1.Controls.Count == 0)
A method that might be easier is to simply hide them. xxx.Visible = false; Then reset them when the tab is selected.
ANAT2403Author Commented:
Hi JimBrandley,
There is no option of visible for the tabPages of the tabcontrol.
But I found the solution for the problem:
If I write
 tabCtrlLinking.SelectedIndex = -1 in the form load so no tab is selected and now if I select a tab
it will show this tab!

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now