I want to load another form inside the main form panel. Once another form is chosen the main form needs to be removed and the new one should be set to the panel.
Main Form
Second Form
Code
this.Wrapper.Controls.Clear();
this.Wrapper.Visible = true;
FrmCompany frm = new FrmCompany()
{
Width = this.Wrapper.Width,
Height = this.Wrapper.Height,
TopLevel = false,
AutoScroll = true,
ControlBox = false,
Dock = DockStyle.Fill,
WindowState = FormWindowState.Maximized,
Style = MetroColorStyle.Default
};
this.Wrapper.Controls.Add(frm);
frm.Left = 0;
frm.Top = 0;
frm.Show();
If want to display a form inside a panel then do something like this
private void button1_Click(object sender, EventArgs e)
{
Form2 newofrm = new Form2();//new instance
newofrm.TopLevel = false;//allow to added to panel
this.panel1.Controls.Add(newofrm);// add to panel
newofrm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;// remove boarder
newofrm.Dock = DockStyle.Fill;// completely fill panel
newofrm.Show();// show the form
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.