Reputation: 27733
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.
Upvotes: 2
Views: 3151
Reputation: 273844
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.
Upvotes: 3
Reputation: 33950
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.
Upvotes: 0
Reputation: 45127
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.
Upvotes: 0