C# 编写菜单的使用问题讲解
1、源代码private void toolStripMenuItem1_Click(object sender, EventArgs e)
{
//点击展开(关闭)其他项钮的事件
switch (i)
{
case 1:
this.设置密码ToolStripMenuItem.Visible = false;
this.添加用户ToolStripMenuItem.Visible = false;
this.忘记密码ToolStripMenuItem.Visible = false;
this.修改密码ToolStripMenuItem.Visible = false;
this.员工录入ToolStripMenuItem.Visible = false;
i = 2;
this.操作ToolStripMenuItem.ShowDropDown();
break;
case 2:
this.设置密码ToolStripMenuItem.Visible = true;
this.添加用户ToolStripMenuItem.Visible = true;
this.忘记密码ToolStripMenuItem.Visible = true;
this.修改密码ToolStripMenuItem.Visible = true;
this.员工录入ToolStripMenuItem.Visible = true;
i = 1;
this.操作ToolStripMenuItem.ShowDropDown();
break;
}
}
2、如果只是初始窗体时,控制菜单的是否可见,只要设置菜单项的Visible属性即可、
3、此处特殊点是this.操作ToolStripMenuItem.ShowDropDown();
无此句时,点击后系统自动关闭菜单,认为是执行按钮事件后结束,菜单刷新了看不见,需要点击菜单才能观察;加入此句后,菜单更新并且不关闭,用户可以直接看到菜单的变化。
补充:软件开发 , C# ,