Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Load Form inside panel other form in win app

Tags:

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 objForm= SubForm.InstanceForm(); this.IsMdiContainer = true; objForm.TopLevel = false; pnlSubSystem.Controls.Add(objForm); objForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; objForm.Dock = DockStyle.Fill; objForm.Show(); 

now I want to show other form on subForm of this panel, But I dont know how to do it.

like image 489
Iraj Avatar asked Jul 31 '13 05:07

Iraj


2 Answers

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(); 
like image 69
M.Mohammadi Avatar answered Oct 03 '22 05:10

M.Mohammadi


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);  
like image 45
Martijn van Put Avatar answered Oct 03 '22 06:10

Martijn van Put