C# Windows Form - Open a MDI Child Window in a Tab Control

I using C# to create a winform in .NET 2.0 with VS 2005.  I want to open all MDI child forms in their own seperate tab inside the tab control - how do I do this?
tsmolskowAsked:
Who is Participating?
 
Fahad MukhtarDistinguished EngineerCommented:
           Form2 frm= new Form2();            //child form
            frm.TopLevel = false;
            TabPage tp = new TabPage(frm.Text);
            tabControl1.TabPages.Add(tp);
            frm.Parent  = tp;
            frm.Show();
0
 
tsmolskowAuthor Commented:
It works with one change - you have to use ActiveForm.Text - see below

            Form2 frm= new Form2();            //child form
            frm.TopLevel = false;
            TabPage tp = new TabPage(frm.ActiveForm.Text );
            tabControl1.TabPages.Add(tp);
            frm.Parent  = tp;
            frm.Show();
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.