tabcontrol in winforms

Posted on 2007-07-26
Last Modified: 2009-02-23
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.
Question by:ANAT2403
    LVL 6

    Expert Comment

    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)
    LVL 22

    Expert Comment

    A method that might be easier is to simply hide them. xxx.Visible = false; Then reset them when the tab is selected.

    Accepted Solution

    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!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now