C#编程:查找窗体内某种控件,并进行属性设置

伢赞

关注

阅读 30

2022-05-09


C#编程:查找窗体内某种控件,并进行属性设置_编程开发

private void button3_Enter(object sender, EventArgs e)
{
foreach (Control tempcon in this.Controls)
{
switch (tempcon.GetType().ToString())
{
case "System.Windows.Forms.Label":

break;
case "System.Windows.Forms.Panel":

break;
case "System.Windows.Forms.GroupBox":

break;
case "System.Windows.Forms.Button":
tempcon.Enabled = false;
break;
}
}

Thread.Sleep(3000);

foreach (Control tempcon in this.Controls)
{
switch (tempcon.GetType().ToString())
{
case "System.Windows.Forms.Label":

break;
case "System.Windows.Forms.Panel":

break;
case "System.Windows.Forms.GroupBox":

break;
case "System.Windows.Forms.Button":
tempcon.Enabled = true;
break;
}
}
}



精彩评论(0)

0 0 举报