views:

277

answers:

1

I have a subform (child) that I want to use in a number of parents. I'm not a professional developer (I'm an architect - I know, you can save all the jokes... :) - working solo at present). I've ended up using an MDI form with the subform as a child. I maximize the subform form and most things are fine except that although I've tried to disable all the various widgets (the subform in the designer shows NO caption/icon/button area), I get TWO icons on the left and TWO sets of buttons on the right - of which ONLY the restore button works. Either of the sets of buttons will work the one child form.

Is there any way around this? I want the subform to be "transparent" the the user - they shouldn't be aware there's a subform in use.

I've done a quick search and I'd already suppressed the actual caption as mentioned in another answer - to get the caption bar suppressed in the designer...

Is MDI the right technology, or is there a better way to have the same subform appear in multiple parent forms?

VS2008, C#, Windows 7

TIA, Paolo

A: 

There's a WF bug that will double the glyphs if you create the MDI child form in the parent's constructor. Here's an example:

public partial class Form1 : Form {
    public Form1() {
        InitializeComponent();
        this.IsMdiContainer = true;
        var child = new Form();
        child.MdiParent = this;
        child.WindowState = FormWindowState.Maximized;
        child.Show();
    }
}

Move the child form creation code to the Load event to avoid this.

Hans Passant
Thanks Hans!That's got rid of the "doubling up". Now, is there any way to suppress the "bar" entirely?
PaoloFCantoni
No, everything is private, you cannot mess with it. There is no point in using MDI if you always run the child forms maximized.
Hans Passant
I do intend to use the child form maximized. So how do I couple the child with the parent without MDI - just a pointer would be good. I'm just not sure what the mechanism to use is. Remember , I'm just an architect (and a Data one at that! :) )
PaoloFCantoni
Just use a UserControl.
Hans Passant
Thanks for the direction Hans, the UserControl is working and I now have some UserControl issues but the question I have has now been answered!
PaoloFCantoni