Raise an event from a User Control.

I created a user control, let's just say this user control "Simpsons".
"Simpsons" control has some other controls on it, let's call them
"Homer", "Marge" and "Bart".
"Simpsons" should raise a "Click" event, whether the user clicks "Simpsons" itself or "Homer" or "Marge". How can I achieve this

Thank you for your help!

P.S : The names of my controls are NOT actually "Simpsons","Homer","Marge" or "Bart." :-)


Answer this question

Raise an event from a User Control.

  • fatih_saki

    It had written an article to do this long back. You can read it up. BTW: I am not sure if the sample code will work as-is since it was written in .NET v1.0 Beta2

    [ http://www.mastercsharp.com/article.aspx ArticleID=67&&TopicID=2 ]

    Redards,
    Saurabh Nandu
    www.MasterCSharp.com
    www.AksTech.com

  • bitumen

     Jeong-hun wrote:
    I created a user control, let's just say this user control "Simpsons".<br />"Simpsons" control has some other controls on it, let's call them<br />"Homer", "Marge" and "Bart".<br />"Simpsons"&nbsp;should&nbsp;raise a "Click" event,&nbsp;whether the user clicks "Simpsons" itself or "Homer" or "Marge". How can I achieve this <br /><br />Thank you for your help!<br /><br />P.S : The names of my controls are NOT actually "Simpsons","Homer","Marge" or "Bart." :-)

    I'm relatively new around so there's most likely another and better way to do this but what I would do is this:
    Create the SimpsonsOnClick method and just call it whenever the user click on homer, marge or bart (as well as on simpsons ofcourse).

  • Raise an event from a User Control.