这是我用来显示面板的代码:
foreach (var c in Controls)
{
if (!(c is Panel)) continue;
if (c.Name == "pnlBottom") continue;
c.Visible = c.Name.Contains(_currentPanel.ToString());
if (c.Visible) return;
}
这是我用来调用它并浏览我的面板的代码:
下一步按钮
private void btnNext_Click(object sender, EventArgs e)
{
if (pnlContent1.Visible) { ShowPanel("2"); return; }
if (pnlContent2.Visible) { ShowPanel("3"); return; }
if (pnlContent3.Visible) { ShowPanel("4"); return; }
if (pnlContent4.Visible) { ShowPanel("5"); return; }
}
返回键
private void btnBack_Click(object sender, EventArgs e)
{
if (pnlContent2.Visible) { ShowPanel("1"); return; }
if (pnlContent3.Visible) { ShowPanel("2"); return; }
if (pnlContent4.Visible) { ShowPanel("3"); return; }
if (pnlContent5.Visible) { ShowPanel("4"); return; }
}
我希望这也将用于其他人:D!