日期:2014-05-17  浏览次数:20952 次

toolStrip1的问题
我想让toolStrip1中的一个button可用,其他的控件都不可用

 this.toolStrip1.Enabled = false;
 button.Enabled = true;

这样写为什么不可以

------解决方案--------------------
            foreach (ToolStripItem tool in toolStrip1.Items)
            {
                if (tool.Text == "toolStripButton1")
                {
                    tool.Enabled = true;
                }
                else
                    tool.Enabled = false;
            }
------解决方案--------------------
不可以的,你遍历toolStrip1的控件才行
foreach(Control c in toolStrip1.Items)
   c.Enabled=false;

button.Enabled=true;