首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

toolStrip1的有关问题

2013-04-09 
toolStrip1的问题我想让toolStrip1中的一个button可用,其他的控件都不可用 this.toolStrip1.Enabled fal

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;

热点排行