Form2 f2;
Form3 f3;
private void btnMessageType_Click(object sender, EventArgs e)
{
this.panel_main.Controls.Clear();
f2 = new Form2(); //实例化窗体FORM2
f2.TopLevel = false; //设置为非顶级窗体
f2.FormBorderStyle = FormBorderStyle.None; //设置窗体为非边框样式
f2.Dock = System.Windows.Forms.DockStyle.Fill; //设置样式是否填充整个PANEL
this.panel_main.Controls.Add(f2); //添加窗体
f2.Show();
}
private void button1_Click(object sender, EventArgs e)
{
this.panel_main.Controls.Clear();
f3 = new Form3(); //实例化窗体FORM2
f3.TopLevel = false; //设置为非顶级窗体
f3.FormBorderStyle = FormBorderStyle.None; //设置窗体为非边框样式
f3.Dock = System.Windows.Forms.DockStyle.Fill; //设置样式是否填充整个PANEL
this.panel_main.Controls.Add(f3); //添加窗体
f3.Show();
}