分享

C#panel控件问题

 ylw527 2010-11-18
在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();
}

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多