如何使多个TextBox为只读!别说放在Panel里,用enable呀,我试了,那样都是灰的,太难看了

解决方案 »

  1.   

    use a loopforeach(Control c in YourPanel.Controls)
    {
       TextBox t = c as TextBox;
       if (t != null)
    t.ReadOnly = true;
    }
      

  2.   

    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
      

  3.   

    刚才的差了一点,应该是下面这个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