在FORM1 里有个 panel 和3个button 我想点击butto1 就在panel显示FORM2 button2就显示FORM2
private void button1_Click(object sender, EventArgs e)
{ Form f = new Form1(); this.ShowFormInPanel(f, this.panel1); } private void button2_Click(object sender, EventArgs e) { Form f = new Form2(); this.ShowFormInPanel(f, this.panel1); } private void button3_Click(object sender, EventArgs e) { Form f = new Form3(); this.ShowFormInPanel(f, this.panel1); } private void ShowFormInPanel(Form f, Panel AParent) { f.Top = 0; f.Left = 0; f.TopLevel = false; // f.FormBorderStyle = FormBorderStyle.None; AParent.Controls.Add(f); // f.Parent = AParent; // f.Dock = DockStyle.Fill; f.Show(); // f.BringToFront(); // f.Focus(); } |
|