Events in user controls

Posted on 2005-04-11
Last Modified: 2010-04-23
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?
Question by:pamwestphal
    LVL 25

    Expert Comment

    to get the activecontrol just use

    LVL 25

    Accepted Solution

    or add an event to your usercontrol


        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

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Join & Write a Comment

    If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
    Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now