tags:

views:

117

answers:

1

I am showing my MDI windows inside the main form but in one part of the splitter panel, like this:

    Form2 f2= new Form2();
    f2.MdiParent = this;
    f2.Parent = this.splitContainer2.Panel2;
    f2.Show();

but the problem is that I cannot cascade them if I write a code like this:

this.LayoutMdi(System.Windows.Forms.MdiLayout.Cascade);

"this" is the parent form. the main form.

Hoe can I cascade them?

thanks all.

A: 

You'll have to override the LayoutEngine for the SplitContainer panel. Microsoft has a good example here for creating a custom layout engine.

private void CascadeToolStripMenuItem_Click(object sender, EventArgs e) {
        //LayoutMdi(MdiLayout.Cascade);
        Rectangle bounding = this.splitContainer1.Panel1.DisplayRectangle;
        Point nextFormLocation = bounding.Location;
        foreach (Control c in this.splitContainer1.Panel1.Controls) {
            if (!c.Visible) {
                continue;
            }

            nextFormLocation.Offset(c.Margin.Left, c.Margin.Top);

            c.Location = nextFormLocation;
            c.BringToFront();

            if (c.AutoSize) {
                c.Size = c.GetPreferredSize(bounding.Size);
            }

            nextFormLocation.X = bounding.X + 20;

            nextFormLocation.Y = bounding.Y + 20;

        }
    }

just add the above code to your cascade button and you'll get the basics of cascade.

BuildStarted
Ok, thanks.but still I am not clear how to make the CaseCade to work ?:(
BDotA
hmm...i can't reply with the code so i'm going to add another answer
BuildStarted
very much appreciated.
BDotA