Hi,

I have multiple Controls grouped in Groupboxes. I want to select the control from groupbox dynamically. For example, I am able to select the controls from GroupBox1 with the code below. However, I want to make it dynamically so that users can select any controls from any GroupBox.

Would appreciate your help and suggestion.
Thank you.

 Private Sub addSelectedClickHandlers()
        Try

            For Each selectedControl As Control In GroupBox1.Controls

                AddHandler selectedControl.MouseMove, AddressOf selectedControl_MouseMove

                AddHandler selectedControl.MouseLeave, AddressOf selectedControl_MouseLeave

            Next

        Catch ex As Exception

            Debug.Print(ex.ToString)

        End Try

    End Sub

You might try something like this.....

 Private Sub addSelectedClickHandlers(ByVal gb As GroupBox)


Try

            For Each selectedControl As Control In gb.Controls

                AddHandler selectedControl.MouseMove, AddressOf selectedControl_MouseMove

                AddHandler selectedControl.MouseLeave, AddressOf selectedControl_MouseLeave

            Next

        Catch ex As Exception

            Debug.Print(ex.ToString)

        End Try

    End Sub
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.