0

I have two forms that I am trying to display on a master form using a tabControl element in C#.

I have had no luck so far. How does one go about it?

3
  • 1
    Generally speaking, you don't display a form within a form. What are trying to accomplish? Can you not create a set of controls within the TabPage on the TabControl? What have you tried and what have you "not had any luck" with? You'll find no help here unless you show what you've actually tried.
    – sab669
    Aug 5, 2015 at 14:28
  • If it is possible instead of creating two forms, create a model popup of those forms in your Master page.
    – TFrost
    Aug 5, 2015 at 14:45
  • I am kinda new to C# and on a RAD project, thanks for your help @sab669
    – K3RAMA
    Aug 5, 2015 at 16:22

2 Answers 2

1

In your "Child" form, put all your control in a Panel (let's call it "movingPanel") with its Dock property set to Fill and its Modifiers property set to internal. After creating, the child form in the master form, simply do:

 theChildForm.movingPanel.Parent = tabControl1.TabPages["The_tabPage_Name"] ;   
0

If you want to host your form into a tab page I think this part of code helps :

newForm.TopLevel = false;
newForm.ControlBox = false;
newForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
newForm.Dock = DockStyle.Fill;
var newTab = new TabPage()
newTab.Controls.Add(newForm);
this.MainTabControl.TabPages.Add(newTab);
this.MainTabControl.SelectedTab = newTab;
newForm.Show();

I hope this is what you are looking for.

1
  • The key here is that you must set Form.TopLevel to false before adding the form to a container and displaying it.
    – Idle_Mind
    Aug 5, 2015 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.