1

I have a parent form with a button and when in the click event of the button I want to open a new form.

Form2 form2= new Form2(); form2.Show(); 

But, form2 is opened as a separate process. I want the form to opened inside the parent form.

While googled I found out that MDI is being deprecated. So could you please suggest me a good way?

7
  • 4
    MDI is being deprecated in favor of WPF, if you use winforms, MDI is still useful. However the style of MDI is actually old. Commented Aug 25, 2013 at 13:12
  • 1
    It's not quite clear how you create form2 as as a separate process. Do you really mean that? Commented Aug 25, 2013 at 13:59
  • @KingKing : I am using winforms.So how to use MDI?? Commented Aug 25, 2013 at 14:37
  • @avo: form2 as a separate process means its showing as a separate screen.Not as a Form inside the main form Commented Aug 25, 2013 at 14:38
  • @Mothy Using MDI is simple, some search will lead you to more sample code. The most important properties you should look at are MdiParent, MdiChildren and to turn a form into a MDI form, just set IsMdiContainer = true. Commented Aug 25, 2013 at 14:47

2 Answers 2

4

While googled I found out that MDI is being deprecated

This is like Mark Twain's famous quote: "The reports of my death have been greatly exaggerated". MDI is built into Windows, many old programs depend on it. It has been around for over 25 years and is not going away anytime soon.

Programmers like to arbitrarily announce something deprecated when they don't like a feature. Sure, nobody is that smitten with MDI. That WPF didn't implement it doesn't make it deprecated, that would make shell notify icons deprecated too and they certainly are alive and well. MDI was a windowing model that was invented to deal with the kind of monitors users had 25 years ago. And 640 x 480 displays don't leave a lot of room for windows. Finding a way to make overlapping windows manageable was its primary goal.

It doesn't make much sense to still use it on the gigantic monitors we have today. Docking layouts are much more sensible. Visual Studio being a good example. You'll need to go shopping for a library that support it if you don't want to create one yourself. Weifenluo's DockPanelSuite is very popular and has the right price.

Sign up to request clarification or add additional context in comments.

Comments

2
Form f = new Form(); f.TopLevel = false; f.Visible = true; Controls.Add(f); 

enter image description here

7 Comments

I have tried the above code, the form is being added as a control, not as a window inside the main form
@Mothy I don't understand what you mean. What's the difference?
Form 2(child) inside form1(parent) like MDI .
What do you care what it's called? And by the way, a Form is a Control.
@Mothy Please explain what behavior you would like it to have that it doesn't now. You can click on its controls. You can move it. You can resize it. You cannot move it out of the parent-form (which seems to be what you're looking for, because if not - your original code already has that.)
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.