Hey guys,

I was wondering if there is a way to group controls together without using any containers such as panel, group box, or container.

You can put them into a list or dictionary or array.

Public Class Form1
    Private GroupedControls As New List(Of Control)

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        For Each Control As Control In GroupedControls
            If Control.Equals(sender) Then
                Control.Text = "Button Two"
            End If

    End Sub

End Class

Not exactly sure what you mean. If you wanted to group them in the UI then you would use a panel or other thing you specify not with.

This is what i am trying to do.

I have multiple textboxes that needs to be refreshed or altered per user's action.
These textboxes are all over the form and I am unable to put them in a panel or a group box.
But I dont want to have to create a line of code for each one of them because they all take same action once the user makes changes to the form.
So I was wondering if I can group them together and call them by the group name each time I need to alter these textboxes.
I think the first solution that you have above is the one that I've been looking for.

At the bottom of the thread, above the quick reply box, there is a question "Has this thread been answered?" with a link "Mark this Thread as Solved". Click the link.

This question has already been answered. Start a new discussion instead.