Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How can i fire event from UserControl to the Dialog ?

How can i fire event from UserControl to the Dialog ?

Scheduled Pinned Locked Moved C#
questionhelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hi ALL, I have some dialog that hold UserControl that i wrote. On the userControl i have some Button that when i click on him i need to Fire event to the dialog. How do i do it ? Does there is some method "FIRE_EVENT" that through the event? Thanks for any help.

    A 1 Reply Last reply
    0
    • L Lost User

      Hi ALL, I have some dialog that hold UserControl that i wrote. On the userControl i have some Button that when i click on him i need to Fire event to the dialog. How do i do it ? Does there is some method "FIRE_EVENT" that through the event? Thanks for any help.

      A Offline
      A Offline
      Abisodun
      wrote on last edited by
      #2

      In the user control declare a delegate and event: public event ClickHandler Click1; public delegate void ClickHandler(EventArgs e); In the button's click event raise the event: i.e. if (null != Click1) Click1(e); In the dialog add a handler for Click1: myControl.Click1 += YourHandler

      L 1 Reply Last reply
      0
      • A Abisodun

        In the user control declare a delegate and event: public event ClickHandler Click1; public delegate void ClickHandler(EventArgs e); In the button's click event raise the event: i.e. if (null != Click1) Click1(e); In the dialog add a handler for Click1: myControl.Click1 += YourHandler

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        But How does the dialog know about the event ? What i need to know ( and does not understand ) is the dialog know about the existing of the click event before i create the connection between the dialog and the User Control ? Because i need to do it in late banding and i don't want to create connection between the dialog and the User Control in the design time - i want to create this connection in run time - Can i do it ?

        A 1 Reply Last reply
        0
        • L Lost User

          But How does the dialog know about the event ? What i need to know ( and does not understand ) is the dialog know about the existing of the click event before i create the connection between the dialog and the User Control ? Because i need to do it in late banding and i don't want to create connection between the dialog and the User Control in the design time - i want to create this connection in run time - Can i do it ?

          A Offline
          A Offline
          Abisodun
          wrote on last edited by
          #4

          myControl.Click1 += new MyControl.ClickHandler(yourClickHandlerMethodInTheDialog); myControl here is an instance of the user control whose class name is MyControl.

          Yanshof wrote:

          What i need to know ( and does not understand ) is the dialog know about the existing of the click event before i create the connection between the dialog and the User Control ?

          The instance myControl only exists at run time in all cases (even if you're using the VS Designer). -- modified at 8:33 Monday 30th July, 2007

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups