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
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"
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.
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.
For Each ctrl As Control In Me.Controls("pnlMainPanel").Controls
If ctrl.GetType Is GetType(System.Windows.Forms.Panel) Then
For Each subCtrl As Control In ctrl.Controls
If subCtrl.GetType Is GetType(System.Windows.Forms.TextBox) Then
If subCtrl.GetType Is ...