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.
ANAT2403Asked:
Who is Participating?
 
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!
0
 
Bruce_1975Commented:
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()
        {
            InitializeComponent();
            mControls = new Control[tabPage1.Controls.Count];
            tabPage1.Controls.CopyTo(mControls,0);
            tabPage1.Controls.Clear();
        }

and add them again at the first MouseClick

private void tabControl1_MouseClick(object sender, MouseEventArgs e)
        {
            if (tabPage1.Controls.Count == 0)
                tabPage1.Controls.AddRange(mControls);
        }
0
 
JimBrandleyCommented:
A method that might be easier is to simply hide them. xxx.Visible = false; Then reset them when the tab is selected.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.