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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with error in Query 2 31
SSIS On fail action 5 38
Using data from certificate to re-create certificate programmatically 3 26
Problem to Office 1 15
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

829 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