use a loopforeach(Control c in YourPanel.Controls) { TextBox t = c as TextBox; if (t != null) t.ReadOnly = true; }
Dim ctrl As Control Dim box As TextBox For Each ctrl In Page.Controls(1).Controls If TypeOf ctrl Is TextBox Then box = CType(ctrl, TextBox) box.ReadOnly = True If Next
刚才的差了一点,应该是下面这个Dim ctrl As Control Dim box As TextBox For Each ctrl In Page.Controls(1).Controls If TypeOf ctrl Is TextBox Then box = CType(ctrl, TextBox) box.ReadOnly = True End If Next
{
TextBox t = c as TextBox;
if (t != null)
t.ReadOnly = true;
}
Dim box As TextBox
For Each ctrl In Page.Controls(1).Controls
If TypeOf ctrl Is TextBox Then
box = CType(ctrl, TextBox)
box.ReadOnly = True
If
Next
Dim box As TextBox
For Each ctrl In Page.Controls(1).Controls
If TypeOf ctrl Is TextBox Then
box = CType(ctrl, TextBox)
box.ReadOnly = True
End If
Next