Go Premium for a chance to win a PS4. Enter to Win

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
?
490 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 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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 anti-spam), the admin…

916 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