Powersee(this.menuStrip.Items);
private void Powersee(ToolStripItemCollection toolStripItemCollection)
{
// foreach (ToolStripMenuItem c in toolStripItemCollection)//因为有线
for(int i=0;i<toolStripItemCollection .Count ;i++)
{
if (toolStripItemCollection[i] is System.Windows.Forms.ToolStripMenuItem)
{
ToolStripMenuItem ck = toolStripItemCollection[i] as ToolStripMenuItem;
if (ck.Tag != null)//有TAG,那它就是要控制的
{
ck.Enabled = false;//首先是关掉它
if (UMenu.Contains("," + ck.Tag.ToString() + ","))
{
ck.Enabled = true;//有权限才打开
if (ck.DropDownItems.Count > 0)
{
Powersee(ck.DropDownItems);
}
}
}
}
}
}