• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 180
  • Last Modified:

Events in user controls

I have created a user control.  I want to handle the Click event from the form that they are placed on.  These controls are dynamically loaded into an array of the control type and then added to the contol matrix.  Is this even possible?  If not is thier a way that I can use the Click event on the form to detect which user contorl I am located on?
0
pamwestphal
Asked:
pamwestphal
  • 2
1 Solution
 
RonaldBiemansCommented:
to get the activecontrol just use

Me.ActiveControl
0
 
RonaldBiemansCommented:
or add an event to your usercontrol

like

    Public Event ClickedON(ByVal sender As Object)


    Private Sub UserControl2_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Enter
        RaiseEvent ClickedON(sender)
    End Sub

and in your form

do something like

AddHandler UserControl21.ClickedON, AddressOf usercontrolEntered


Private Sub usercontrolentered(ByVal sender As Object)
        MsgBox(CType(sender, UserControl2).Name)
    End Sub
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now