首页 > 代码库 > Panel of WinForm
Panel of WinForm
在Winform中使用Panel时要注意的问题:
当几个panel的大小相同,位置相同时就要注意
panel之间是否会出现重叠的问题了,一般情况下(重叠的时候):
private void toolStripMenuItem1_Click(object sender, EventArgs e)
{
panel1.Visible = false;
groupBox1.Visible = true;
panel2.Visible = false
}
private void toolStripMenuItem2_Click(object sender, EventArgs e)
{
panel1.Visible = true;
groupBox1.Visible = false;
panel2.Visible = false;
}
private void toolStripMenuItem3_Click(object sender, EventArgs e)
{
panel2.Visible = true;
panel1.Visible = false;
groupBox1.Visible = false;
}
即,只要你在打开目标Panel,然后关闭其他即可,但是,如果你把Panel的位置和大小相同,就又可能把后来放的Panel放在了前面Panel的上面,而当你在后面要打开Panel2或grouBox时你却关闭了它本所在的Panel,所以不可能看到你想要看到的结果;
即,你在关闭之前的Panel之前一定要先确定你要打开的Panel的位子。
如
private void toolStripMenuItem1_Click(object sender, EventArgs e)
{
panel1.Visible = false;
groupBox1.Visible = true;
}
private void toolStripMenuItem2_Click(object sender, EventArgs e)
{
//Panel1 in groupBox1s so can not close the groupBox
panel1.Visible = true;
//groupBox1.Visible = false;
panel2.Visible = false;
}
private void toolStripMenuItem3_Click(object sender, EventArgs e)
{
//panel2 in panel1.so
panel2.Visible = true;
}
三个Panel在一起