简体   繁体   中英

C# - WinForms - SDI or MDI Approach?

I am creating a Visual C# WinForms application that will contain 4 forms:

  1. A "control" form that will have anywhere between 2 buttons and potentially up to 10 or so. So the screen will need to accommodate enough space for the maximum amount of buttons.
  2. A "logging" form that will contain a large rich textbox control.
  3. A "config" form that will contain a tab control with various configuration settings that can be tweaked.
  4. A "order log" form that's very similar to #2.

It's likely that the user will want to reposition each of these forms in different ways. Yet, I would like these forms to be "managed" by a parent form so that when the application closes, all of the other forms close. Is there a way to keep the MDI approach, yet allow the child forms move outside of the parent form using C# WinForms? Thanks!

usually for such cases you would use the "docking" feature. same way is done in Visual Studio itself. This way user can hide/show very easy the forms.

Such a package doesn't come with Visual Studio, but there are free libraries for this. Check this out http://sdock.codeplex.com/ for example.

You can do just about anything you want.

You can establish a parent-child relationships between the forms. Or, if you want, you can explicity close the other forms when the main form is closed.

Most systems are moving away from MDI (like Office for example), so I would probably go with an SDI-style interface, even if you have several forms. MDI tends to not make good use of the screen real-estate, and most modern users are not accustomed to dealing with some of its quirks.

I have worked with MDI applications a bit and have tried something similar.

There are a few things I have learned from experience that you should consider before you decide.

One thing I have noticed with MDI's is that the forms and controls seem to paint a little slower than regular forms. So when you click a link/button and throw up a new child form, you can see it visually paint the new child form onto the screen, which makes your application seem sluggish. This has been tested on a huge host of hardware/OS combinations and with test applications that aren't doing anything but opening a form with some controls on it.

Another thing about MDI is your child windows will be contained within the parent window, which works for some applications, but is annoying for others.

Another quirk with MDI is that you cannot use window transparency, if you have such a need for that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM