Start New Discussion within our Software Development Community

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
This article has been dead for over six months. Start a new discussion instead.