2

I have a set of well-behaved Windows Forms that are embedded in DLL's that I do not have full control over. These are part of a separate legacy projects that I'm trying to unify under one interface so that the application doesn't quite feel like popup hell.

I think the way to do this is to create an MDI parent form, and open the other forms as children of that. One child form at a time as they're needed. As they navigate one MDI document will close, and another will open.

The parent MDI form though, needs navigation controls. And I'd like to use a tabcontrol. Is it possible to attach a tabcontrol to the parent MDI form? All I can find documentation for and examples of are toolstrips, but that's far too limiting for what I want to accomplish.

No code to show, sorry. I'm not sure if what I want is possible at all.

Update As indicated below, I really didn't need MDI to accomplish what I set out to do. Leaving the question as-is, however.

Clinton Pierce
  • 12,859
  • 15
  • 62
  • 90

1 Answers1

3

If I've read this correctly, then I don't think MDI is what you are looking for, since you want to use a TabControl to navigate to each form.

If you turn TopLevel to false and remove the border from a Form, you essentially turn the form into a UserControl, and can add it to the TabPage panel of your choosing:

  Form f = new Form();
  f.TopLevel = false;
  f.FormBorderStyle = FormBorderStyle.None;
  f.Dock = DockStyle.Fill;
  tabPage1.Controls.Add(f);
  f.Visible = true;

Change Form to a form you are referencing from your DLL.

LarsTech
  • 80,625
  • 14
  • 153
  • 225
  • You're right, I think I overcomplicated this by dragging MDI through it all. This will possibly work and I'll mark the answer as soon as I verify. Thank you. – Clinton Pierce Jan 21 '13 at 20:38
  • I don't see how this can work. According to TabControl, only TabPages can be added, not forms. Other SO pages respond to use MDI. https://stackoverflow.com/questions/5796334/embed-a-form-onto-a-tabcontrol-in-windows-forms?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa – erict Apr 17 '18 at 19:33
  • @erict The form is being added to the *Controls* collection of the TabPage. – LarsTech Apr 17 '18 at 19:38