for(int i=0;i<this.Controls.count;i++)
{
if (this.Controls[i].Name = name)
{
(this.Controls[i] as Button).enable = false;
}
}
其实最好还是用is 判断一下,比如 你是button的话,加一句if (this.Controls[i] is Button)
{
if (this.Controls[i].Name = name)
{
(this.Controls[i] as Button).enable = false;
}
}
其实最好还是用is 判断一下,比如 你是button的话,加一句if (this.Controls[i] is Button)
或者考虑用用handle来看看
{
if (this.Controls[i].Name = name)
{
if(this.Control[i] is Button) then
{
(this.Controls[i] as Button).enable = false;
}
}
}