Click here to Skip to main content
11,922,641 members (31,956 online)
Click here to Skip to main content
Add your own
alternative version


93 bookmarked

Tabbed MDI Child Forms

, 13 Feb 2007
Rate this:
Please Sign up or sign in to vote.
An article about browsing MDI child forms on tab page


MDI child forms on tab page like Internet Explorer 7. So easy to use and a little code necessary.

Using the code

First, set isMDIContainer property of the parent form to true. Add a TabControl component to the main form and set the Dock property to Top. Delete all tab pages of TabControl and set the Name property to tabForms and set the Visible property to false.

No any code necessary for child forms. All codes in main forms.

When the MDI Child Form is activated; if child form has a tab page, activate the corresponding tab page else create a tab page for child form and select tab page.

private void Form1_MdiChildActivate(object sender, 
                                    EventArgs e) 
    if (this.ActiveMdiChild == null) 
        tabForms.Visible = false; 
        // If no any child form, hide tabControl 
        this.ActiveMdiChild.WindowState = 
        // Child form always maximized 

        // If child form is new and no has tabPage, 
        // create new tabPage 
        if (this.ActiveMdiChild.Tag == null) 
            // Add a tabPage to tabControl with child 
            // form caption 
            TabPage tp = new TabPage(this.ActiveMdiChild
            tp.Tag = this.ActiveMdiChild; 
            tp.Parent = tabForms; 
            tabForms.SelectedTab = tp;
            this.ActiveMdiChild.Tag = tp; 
            this.ActiveMdiChild.FormClosed += 
                new FormClosedEventHandler(

        if (!tabForms.Visible) tabForms.Visible = true;


When the MDI Child Form is closing, destroy the corresponding tab page. Add the following code to main form.

private void ActiveMdiChild_FormClosed(object sender, 
                                    FormClosedEventArgs e)
    ((sender as Form).Tag as TabPage).Dispose(); 

When a tab page selected, activate its child form

private void tabForms_SelectedIndexChanged(object sender, 
                                           EventArgs e) 
    if ((tabForms.SelectedTab != null) && 
        (tabForms.SelectedTab.Tag != null)) 
        (tabForms.SelectedTab.Tag as Form).Select(); 


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Software Developer (Senior) Anafen Dershanesi
Turkey Turkey
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionMessage Removed Pin
Christofer Padilla4-Jun-15 7:36
memberChristofer Padilla4-Jun-15 7:36 
QuestionChildforms are not showing any controls within Pin
Sunil TG7-May-14 21:28
memberSunil TG7-May-14 21:28 
QuestionTabbed MDI Child Forms Pin
pujits30-Mar-12 22:00
memberpujits30-Mar-12 22:00 
QuestionThank alot Pin
dinhnq14-Nov-11 12:29
memberdinhnq14-Nov-11 12:29 
GeneralThanks Pin
Sid Hatedhillson9-Nov-11 17:19
memberSid Hatedhillson9-Nov-11 17:19 
GeneralGood job man Pin
zarkodolas7-Apr-11 7:04
memberzarkodolas7-Apr-11 7:04 
Good job man, you developped just enough to let us modify according to our needs.

GeneralMy vote of 3 Pin
Hamed Almighty23-Aug-10 19:58
memberHamed Almighty23-Aug-10 19:58 
GeneralFix for flicker when changing tabs Pin
Stevekoeniger4-Aug-10 9:59
memberStevekoeniger4-Aug-10 9:59 
GeneralRe: Fix for flicker when changing tabs Pin
Rolf Kristensen8-Oct-10 21:26
memberRolf Kristensen8-Oct-10 21:26 
GeneralRe: Fix for flicker when changing tabs Pin
muddu krishna2-Mar-12 2:25
membermuddu krishna2-Mar-12 2:25 
GeneralRe: thanks Stevekoeniger Pin
nzzzn128-Mar-15 22:38
membernzzzn128-Mar-15 22:38 
QuestionHello Pin
pac398-Dec-08 8:23
memberpac398-Dec-08 8:23 
GeneralGood work Pin
peitor11-Jun-08 2:44
memberpeitor11-Jun-08 2:44 
Questionwhy do the some normal size child forms repidly shows and disappaired when I clicked tab pages? Pin
Jason.Han11-Feb-08 19:40
memberJason.Han11-Feb-08 19:40 
GeneralProgramatic change of child didn't sync the tabs Pin
Scott S.7-Dec-07 6:03
memberScott S.7-Dec-07 6:03 
GeneralHide control box Pin
powermetal3-Oct-07 9:53
memberpowermetal3-Oct-07 9:53 
Questionproblem with the instances Pin
ALKADI4-Jul-07 15:32
memberALKADI4-Jul-07 15:32 
AnswerRe: problem with the instances Pin
Serdar YILMAZ21-Sep-07 10:39
memberSerdar YILMAZ21-Sep-07 10:39 
GeneralRe: problem with the instances Pin
ALKADI22-Sep-07 12:02
memberALKADI22-Sep-07 12:02 
GeneralRe: problem with the instances Pin
Scott S.7-Dec-07 6:07
memberScott S.7-Dec-07 6:07 
GeneralRe: problem with the instances Pin
Serdar YILMAZ13-Dec-07 5:48
memberSerdar YILMAZ13-Dec-07 5:48 
GeneralRe: problem with the instances Pin
Scott S.18-Dec-07 3:36
memberScott S.18-Dec-07 3:36 
QuestionRe: problem with the instances Pin
DSatterlund17-Aug-09 7:55
memberDSatterlund17-Aug-09 7:55 
GeneralTabbed Mdi Pin
muskan815-Jun-07 6:10
membermuskan815-Jun-07 6:10 
GeneralRe: Tabbed Mdi Pin
Serdar YILMAZ15-Jun-07 6:44
memberSerdar YILMAZ15-Jun-07 6:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.151125.1 | Last Updated 14 Feb 2007
Article Copyright 2007 by Serdar YILMAZ
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid