VB.NET - Iterating through controls in a container object

后端 未结 10 1342
别那么骄傲
别那么骄傲 2020-12-03 05:18

I have a form with a \"Clear\" button.

When the user clicks \"Clear\", I want to clear the value of all the visible elements on the form. In the case of date contro

10条回答
  •  悲&欢浪女
    2020-12-03 05:45

    here is the code to get all control of a Form's All GroupControls and you can do something in the GroupBox Control

    Private Sub GetControls()
        For Each GroupBoxCntrol As Control In Me.Controls
            If TypeOf GroupBoxCntrol Is GroupBox Then
                For Each cntrl As Control In GroupBoxCntrol.Controls
                    'do somethin here
    
                Next
            End If
    
        Next
    End Sub
    

提交回复
热议问题