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.
Thanks

Member Avatar for Unhnd_Exception

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
        GroupedControls.Add(Me.Button1)
        GroupedControls.Add(Me.Button2)
        GroupedControls.Add(Me.Button3)
    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
        Next

    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.
Thanks.

this is a random question but how do i mark my thread solved?

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.