Mdiparent - Is this bug solved?

I've an mdiParent (maximized) with X children (maximized). The mdiParent contains a menustrip. I load the children into the parent.

The first time when I load a child into the parent, the menustrip hides a part of the child. When I minimize the parent and then maximize it, the position of the child is correct (below the menustrip).

The same problem: http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=180826&SiteID=1

 




Answer this question

Mdiparent - Is this bug solved?

  • ssuggs

    you said change Form1 to be MdiParent=True!!!

    how is that it should be initially an mdi form, and then assign forms to it as childs

    (i.e: Form1.MdiParent = Me and Me is the MDI form!)



  • andig2

    did you try to use the Activate method like if the form is Form1, you load it in the mdi liek the following:

    Form1.MdiParent = Me
    Form1.Show()
    Form1.Activate()



  • vtcoder

    you see! this step by step scenario that you gave is much better...

    ANSWER TO THE BUG QUESTION:
    this is not a bug, in form2 in initializecomponent, just go to SuspendLayout (or search for it in form2) and remove this line. and then run the applicaiton and the form will show maximized as expected!

    this happens because by default the layout of the form in initializecomponent is suspended, for it to setup multiple controls settings and then resume.


     



  • Don_Ram

    Henri,

    maybe you can try this as workaround. Change the WindowState in the properties to be Normal. In the code you can then set WindowState = FormWindowState.Maximized just before you call Show() method.

    EDIT: It is exactly the same as suggested in the post you linked to but it was not clear to keep the value in the designer properties to be Normal.



  • Matt j Cimino Crawford

    Please do not post duplicate posts. If your question has not received any replies it is most likely because nobody that can give you an answer has replied to it yet. Have some patience.

    Your other post is this one
    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=406055&SiteID=1

    EDIT: other post deleted and keeping this instead.



  • J. Skrzypiec

    sorry Andreas / henri, but it is still unclear, can you give us a step by step scenario to simulate the problem

  • bkavanaugh

    Hmm, but is there nobody dat has the same problem And there isn't a patch o.i.d.

  • Gyða

    There are others, you can track this bug in the product feedback center

    http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx feedbackid=aa68c6a2-5b37-480a-afb5-b0ba8c269c4c

    You can also vote and validate it so it will hopefully get more attention from microsoft.



  • Gokhan Ertas

    Sorry, my mistake. It should be MdiContainer = True. I fixed it in the post.

  • Yankee

    Create new project, use Windows Application template
    Change Form1 to have MdiContainer = True
    Add a menustrip control to Form1

    Add a new form to the project, Form2
    Set Form2 WindowState to be Maximized in the properties at design time

    This code goes into Form1_Load event

    private void Form1_Load(object sender, EventArgs e)
    {
    Form2 f = new Form2();
    f.MdiParent =
    this;
    f.Show();
    }

    When I wrote these steps I noticed that if you do not have WindowState set to Maximized in the properties at design time and only set it when displaying the window in Form1_Load it will actually work as I would expect. Before I only tried to set it again but it seems to be depending on what value it has after creating it.



  • FedericoAX

    You must set the parent als mdiParent before you can use mdiChildren into it.

     

    Form1.MdiParent = Me --------> The Me is the form wich has MdiParent=True

     

    Edit: yes it's true: mdicontainer :)



  • Normality2000

    you are right, but i think we are closer for the cause of this behaviour

  • Emphyrio

    I see no reason why SuspendLayout() should cause the Form2 to render incorrectly as a MDI child, if there is a menustrip. If you remove the menustrip it renders correctly.

    If this is not a bug it is a very strange undocumented requirement for the use of SuspendLayout().

    What you suggest works but it is another workaround. This bug is real.



  • tdanut

    It is very simple to reproduce this bug.

    Create a new project, change Form1 to be MdiContainer=True, add a MenuStrip to Form1. Add another form to the project.

    In Form1_Load, create Form2, set Mdiparent to Form1 and WindowState to Maximized.

    Form2 will be drawn incorrectly, just resizing Form1 will result in Form2 beeing properly painted.

    There was a workaround posted to set WindowState after having shown Form2 but it did not work for me.

    Show/Hide/Show does work to get it painted correctly.

    EDIT: Fixed mistake MdiParent = True should be MdiContainer = True



  • Mdiparent - Is this bug solved?