your own custom event delegate

in MyControl:

public delegate void MyEventHandler(int value, string text);

public event MyEventHandler MyEvent;


protected void ddl_SelectedIndexChanged(object sender, EventArgs e)


DropDownList)sender).SelectedIndex, ((DropDownList)sender).SelectedItem.Text);



in Parent:

this.MyControl.MyEvent += new AAL.FreedomWeb.Web.UI.UserControls.AircraftConfig.MyEventHandler(MyControl_MyEvent);


private void MyControl_MyEvent(int value, string text)


      throw new NotImplementedException();



  • All event handlers should be voids with two parameters, the first being the sender of the event (typed as object) and the second being event arguments (typed as EventArgs or inherited class). Always use the typed event handler delegate EventHandler, there's no reason to create a custom delegate for this ever.

  • Hey! This post couldn't be written any better! Reading this post reminds me of my previous room mate! He always kept talking about this. I will forward this page to him. Pretty sure he will have a good read. Many thanks for sharing!

Comments have been disabled for this content.