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
480 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

685 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