user1491254
user1491254

Reputation: 11

how to re-use my windows forms in a dashboard that works like HTML frames?

My C# standard windows forms app is finished, it has 10 forms. But the new requirement is now to change the "multiple forms" to one dashboard where you click a link on a bar on the side or top and switch between forms in the main area of the dashboard one at a time, pretty much exactly the same way an old HTML frame works with framesets (just imagine my Windows Forms are framesets).

Without going into much detail, each of these forms are pretty involved, multiple threads and so on, and I am looking for a simple trick to display them, as oposed to recoding the entire thing.

I looked at http://www.codeproject.com/Articles/37397/A-Multipanel-Control-in-C but it's not what I want.

Is there a way to do this?

Upvotes: 1

Views: 2003

Answers (3)

user1491254
user1491254

Reputation: 11

I resolved this using MDI as suggested above, works great in .NET Windows Forms 4.0 and 4.5.1.

In the parent form:

Declare a new child form.

myNewChildForm.MdiParent = this;

set child form StartPosition to Manual.

set child form Location to 0,0.

set child form WindowState to Maximized.

set child form Dock to Dockstyle.Fill

That does the trick.

Thank you all.

Upvotes: 0

captray
captray

Reputation: 3638

I would recommend that you either use a tabbed control, or use an MDI Container, or a combination of both. The MDI has some nice behaviors that you'll get for free by implementing it. You could hard code each tab to each form, or have a dropdown that selects each view. If you want to manage the lifecycle of each form, you could implement a singleton pattern on each, or use IOC.

Not entirely sure this is going to solve your problem, but if you have questions or more details, let me know.

Upvotes: 0

Godeke
Godeke

Reputation: 16281

If you convert the forms into custom controls, it then becomes pretty simple to use the TabControl http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol.aspx to display the custom controls on the surfaces of the Tabs it contains.

By making them custom controls you avoid the mixing of the code for each of them (they remain distinct) but they also become easily added to other surfaces. I do this with a UI with a dozen display tabs.

Upvotes: 1

Related Questions