C#遍历窗体所有控件或某类型所有控件 (转)
2021-03-20 08:26
阅读:496
标签:control ble 窗体 pre 复制 enabled 类型 nbsp 代码
foreach (Control control in this.Controls) { //遍历后的操作... control.Enabled = false; }
遍历窗体所有控件,
遍历某个panel的所有控件
foreach (Control control in this.panel4.Controls)
{
control.Enabled = false;
}
遍历所有TextBox类型控件或者所有DateTimePicker控件

foreach (Control control in this.Controls)
{
//遍历所有TextBox...
if (control is TextBox)
{
TextBox t = (TextBox)control;
t.Enabled = false;
}
//遍历所有DateTimePicker...
if (control is DateTimePicker)
{
DateTimePicker d = (DateTimePicker)control;
d.Enabled = false;
}
}

C#遍历窗体所有控件或某类型所有控件 (转)
标签:control ble 窗体 pre 复制 enabled 类型 nbsp 代码
原文地址:https://www.cnblogs.com/wenjie0904/p/12305442.html
下一篇:C# 字母转数字
文章来自:搜素材网的编程语言模块,转载请注明文章出处。
文章标题:C#遍历窗体所有控件或某类型所有控件 (转)
文章链接:http://soscw.com/index.php/essay/66627.html
文章标题:C#遍历窗体所有控件或某类型所有控件 (转)
文章链接:http://soscw.com/index.php/essay/66627.html
评论
亲,登录后才可以留言!