Controls in container form come over child form?

后端 未结 8 2187
天涯浪人
天涯浪人 2020-12-01 20:40

In a container form I have menu and buttons to open ther forms. \"enter

Here I am fac

8条回答
  •  执笔经年
    2020-12-01 20:56

    The main trick here is to treat child forms as Controls. You'll create a child form just like any other control. When you use this method, you have to set it's TopLevel to false - otherwise it won't work.

    The following lines of code are used to create a child form:

    Form childForm = new Form(); //initialize a child form
    
    childForm.TopLevel = false; //set it's TopLevel to false
    
    Controls.Add(childForm); //and add it to the parent Form
    childForm.Show(); //finally display it
    
    childForm.BringToFront(); //use this it there are Controls over your form.
    

    more details here

提交回复
热议问题