views:

838

answers:

3

My app is expanding, but the reqs dictate that there should be only one window open at all times, think of Nodepad where there is a menu, with each menu item different functionality but only one window open at all times as opposed to Excel where a user may have few windows open at once.

So in terms of Windows forms, I was thinking of placing a form within a main form. Then i could load an embedded form needed depending on the user menu choice. OR I could be adding controls to the main form (and their events dynamically depending on the user menu choice). I would use a presenter class for that.

That's just two solution I would use. Do you guys have any tips/experience on how to do it better?

I realize now that I would have to re-write parts of my app, but let's pretend i am starting from scratch.

A: 

It sounds like what you are describing is Multiple-Document Interface (MDI) Applications. Fortunately, there is great support for MDI in WinForms. Here's a quick intro.

JP Alioto
I'd like to upvote this but I'm not 100% sure if it's answering the question because the language of the question is unclear.
AdamRalph
I only went by the tag, so if it's a C# winform, it should apply. :)
JP Alioto
AdamRalph, sorry for not being clear. My application should resemble Nodepad rather than Excel. In Excel you can have several windows open, but in Notepad every time you click to open a doc, the previous one gets closed . Hope this is clear, if its not, I am not sure how else I could explain it. Hence, MDI doesn't make sense for me, as MDI is: "Multiple-document interface (MDI) applications allow you to display multiple documents at the same time, with each document displayed in its own window"
gnomixa
A: 

If your requirements are "one window - multiple functionallity" I would certainly go for a composable UI style of development. The Smart Client Software Factory is a good starting point imo.

Peter Lillevold
+3  A: 

Don't embed Forms, it's not what Forms are for. And it's not necessary.

Put the UI of your modules/sections on UserControls. That keeps it nice and modular and you keep your options open: those UserControls can be directly embedded (1 at a time) in the MainForm or in MDI ChildWindows or in TabPages or ...

Use a Base UserControl (Visual Inheritance) and/or a Interface to implement common functionality.

Henk Holterman
I think that's what I need. Do you happen to have any tutorials (simple ones that show how to do this practice)? Thanks!
gnomixa