• 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.
0
ANAT2403
Asked:
ANAT2403
1 Solution
 
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
 
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

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