MDI Child.show() displays the form in a weird manner

Go To StackoverFlow.com

1

I have a main form that has 5 MDI children. When the main form is created, the mdi children are created and shown as well.

I assign them different locations on the screen, but when they're shown they start with the default location and move in a disturbing way to the new locations. I tried to assign the location before I show the forms , but as expected after calling the.Show() they tend to go to some default location. Is there anyway to avoid showing this movement from the default to the new locations?

Here's a code fragment

groupSettingsForm.Show();
        groupSettingsForm.Location = new Point(0, 0);
        dsForm.Show();
        dsForm.Location = new Point(groupSettingsForm.Width, 0);
        dPlots.Show();
        dPlots.Location = new Point(groupSettingsForm.Width, dsForm.Height);
        alertsForm.Show();
        alertsForm.Location = new Point(groupSettingsForm.Width, dsForm.Height + dPlots.Height);
        dataValuesForm.Show();
        dataValuesForm.Location = new Point(0, groupSettingsForm.Height);

I tried this, but it didn't work for me

   groupSettingsForm.Location = new Point(0, 0);
        groupSettingsForm.Show();

        dsForm.Location = new Point(groupSettingsForm.Width, 0);
        dsForm.Show();

        dPlots.Location = new Point(groupSettingsForm.Width, dsForm.Height);
        dPlots.Show();

        alertsForm.Location = new Point(groupSettingsForm.Width, dsForm.Height + dPlots.Height);
        alertsForm.Show();

        dataValuesForm.Location = new Point(0, groupSettingsForm.Height);
        dataValuesForm.Show();
2009-06-16 07:35
by mustafabar


1

I just had something similar to this - my question can be found here.

You need to set the StartPosition property to FormStartPosition.Manual:

form.StartPosition = FormStartPosition.Manual;
form.Location = new System.Drawing.Point(0, 0);
2009-06-16 09:04
by ChrisF