VB.NET - Iterating through controls in a container object

后端 未结 10 1290
别那么骄傲
别那么骄傲 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:50

    For Each c In CONTAINER.Controls
        If TypeOf c Is TextBox Then
            c.Text = ""
        End If
    Next
    

    Replace the (CONTAINER) by the name of yours (it may be a FORM, a PANEL, a GROUPBOX)
    Pay attention to which you had included your controls in.

提交回复
热议问题