当前位置:
编程学习 >
C#/ASP.NET >>
C# 动态生成textbox,Combobox等控件实例
- 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# ,