In your user control you would provide code something like this:
Code:
private EventHandler clickHandler;
public void SetButtonClickHandler(EventHandler clickHandler)
{
this.clickHandler = clickHandler;
}
Whenever you add a button to the user control you would then just set the Click event handler like this:
Code:
Button myButton = new Button();
myButton.Click += this.clickHandler;
You would then have code like this in your form to provide the event handler:
Code:
private void userControlButtonClick(object sender, System.EventArgs e)
{
MessageBox.Show("A user control button was clicked.");
}
private void button1_Click(object sender, System.EventArgs e)
{
this.myUserControl.SetButtonClickHandler(new EventHandler(this.userControlButtonClick));
}
Edit:
I have tested this with two controls on the same form, but I don't see why it should be any different when one is part of a user control.