您的位置:首页 > 编程语言 > C#

C# 动态生成textbox,Combobox等控件

2010-11-13 02:18 351 查看
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;

}

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: