Solved

How do I create an MDI-like panel framework to embed in an existing MDI Child window in .Net winforms?

Posted on 2011-09-14
5
468 Views
Last Modified: 2012-05-12
Hi:

How do I create an MDI-like panel framework to embed in an existing MDI Child window in .Net winforms?

Our current application is built using a .Net winforms MDI framework.

I'd like to be able to embed a panel in an MDI Child. The panel itself would behave exactly like
an MDI parent with the capability of adding child controls the panel. This should include the ability
to resize, move, position, max/min the child windows within this new panel control. Users should
be able to move freely within the "panel."

The easiest solution would be to embed a new MDI parent (as the panel) within the MDIChild control.
I know that this approach is not possible (at least directly). I really would like to avoid writing my own
home grown custom MDI framework for the panel.

Is there an easy approach that I'm missing here?

Are there any existing implemetations, open source solutions, design patterns 3rd party controls
which already support what I'm trying to do? Although we are winforms based, I wouldn't be opposed
to using WPF for this solution, provided that I can embed the new "panel" within an existing MDI Child window.
(Not sure if that's possible or not.).


Our current applications is a C#/.Net/winforms solution based in VS 2010.

Thanks,
JohnB
0
Comment
Question by:jxbma
  • 3
5 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 36538860
It won't behave ~exactly~ like an MidParent, but you can actually embed normal forms into a Panel by setting the TopLevel() property of the Form to false.

Take a look and play with it to see if it suits your needs:  
public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form3 f3 = new Form3();
            f3.TopLevel = false;
            this.panel1.Controls.Add(f3);
            f3.Show();
        }
    }

Open in new window



*The grey area in Form2 is the Panel: Idle-Mind-500077.flv
0
 
LVL 16

Expert Comment

by:SriVaddadi
ID: 36538874
Set IsMdiContainer property of the windows form  to true
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 36538894
He already has that part...

...his question is really "How do I make an Mdi Child also an Mdi Parent?"
0
 
LVL 1

Author Comment

by:jxbma
ID: 36539431
Hey Idle_Mind:

This looks promising. It gives me some basic functionality very quickly.

I'm assuming that I want to overload positioning, sizing and implement cascade, tiling,
I'll have to hang this behaviour off of events on both the parent & child.

So all you did for this demo was to embed a "vanilla" panel control in an existing MDIChild.
To add "children" to the panel, you simply added the children to the panel's control list.
You did nothing else to get the click and drag behaviour?
Very cool.

Do you see any limitations to this approach that are obvious to you?

Thanks,
JohnB
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 36539643
Exactly.  *Assuming you set TopLevel() to False for the "child" form (otherwise it throws an error!)

Right...the click and drag, moving, resizing, minimizing is all built-in.

Limitations?...yeah, you'd have to implement cascade type things manually.  Also, you don't get ScrollBars on the Panel when a "child" is dragged out of bounds.  There are probably other quirks you'll find... =\

I'm sure there is a third-party library that can truly handle a dual MDI-child-is-also-a-MDI-parent type scenario but I don't know of it (and I'm sure it's not free).
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now