How to Load Form inside panel other form in win app

前端 未结 4 1013
Happy的楠姐
Happy的楠姐 2020-12-29 04:48

I Create a Windows Forms application with C#.

I have a general Form and a panel on it.

I show subForm into this panel with code:

SubForm objF         


        
4条回答
  •  一生所求
    2020-12-29 04:55

    Since you already got the answer that by removing this.IsMdiContainer = true; your code would run perfectly fine. Because IsMdiContainer property changes the display and behavior of the form to an MDI parent form. When this property is set to true, the form displays a submerged client area. All MDI child forms assigned to the parent form are displayed within its client area.

    SubForm objForm= SubForm.InstanceForm();
    objForm.TopLevel = false;
    pnlSubSystem.Controls.Add(objForm);
    objForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
    objForm.Dock = DockStyle.Fill;
    objForm.Show();
    

    objForm form which will be the template for the child forms. Each time you want to create a new child window to your application, you can create a new instance of this template form and make the first form as its parent form.

    //Create a new instance of the MDI child template form
    SubForm objForm = new SubForm(); 
    //Set parent form for the child window 
    objForm.MdiParent=this; // Last ObjForm or something
    //Display the child window
    objForm.Show();
    

提交回复
热议问题