How to Load Form inside panel other form in win app

。_饼干妹妹 提交于 2019-12-02 23:54:37

I think your problem resolved by this code:

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

As I understand, you're very close. To add another form into subform try the same code instead:

pnlSubSystem.Controls.Add(objForm);

use (where objForm2 is the new subForm)

SubForm objForm2 = new SubForm();
objForm.Controls.Add(objForm2); 

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();

Another way:

objForm.TopLevel = false;
objForm.Parent = pnlSubSystem;
objForm.Show();

This is my first answer on Stackoverflow.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!