public static void SetControlsReadOnly(Control control)
{
foreach (Control c in control.Controls)
{
if (c is Panel)
{
SetControlsReadOnly(c);
}
/*
if (c is GroupBox)
{
SetControlsReadOnly(c);
}
if (c is tabControl)
{
SetControlsReadOnly(c);
}
*/
if (c is TabPage)
{
SetControlsReadOnly(c);
}
if (c is TextBox)
{
// 它是 TextBox, 要干什么随便你
System.Windows.Forms.TextBox tb = (System.Windows.Forms.TextBox)c;
//tb.ReadOnly = true;
tb.Enabled = false;
}
else if (c is ComboBox)
{
System.Windows.Forms.ComboBox cb = (System.Windows.Forms.ComboBox)c;
cb.Enabled = false;
}
}
}
C#如何遍历动态生成的textbox,Combobox 等控件
最新推荐文章于 2023-04-18 15:32:42 发布