Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
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
Medium Priority
?
486 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 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 86

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 86

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

AWS Certified Solutions Architect - Associate

This course has been developed to provide you with the requisite knowledge to not only pass the AWS CSA certification exam but also gain the hands-on experience required to become a qualified AWS Solutions architect working in a real-world environment.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

715 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