How to get names of all controls on a panel using vb.net

 
This code sample is for getting names of all control on a panel using vb.net

Code

 Private Sub BtnGetNames_Click(ByVal sender As System.Object, _
                                  ByVal e As System.EventArgs) _
                                  Handles BtnGetNames.Click
   For Each ctrl As Control In Panel1.Controls
       lstControlsNames.Items.Add(ctrl.Name)
   Next
End Sub

You can also use this code sample for any parent control or container controls such as GroupBox etc.

One thought on “How to get names of all controls on a panel using vb.net”

Comments are closed.