Hi All
This might be abit "out there", but here goes:
I have a User Control. And I have a project. How can I have my user control pass a particular "event" to my project, and then have my project run that event?
Hi All
This might be abit "out there", but here goes:
I have a User Control. And I have a project. How can I have my user control pass a particular "event" to my project, and then have my project run that event?
In your UserControl
public delegate void BigEventHandler(object sender, EventArgs e);
public event BigEventHandler SomeThingBigHappened;
private void button1_Click(object sender, EventArgs e)
{
OnSomeThingBigHappened(e);
}
protected virtual void OnSomeThingBigHappened(EventArgs e)
{
SomeThingBigHappened(this, e);
}
In your form
private void userControl11_SomeThingBigHappened(object sender, EventArgs e)
{
MessageBox.Show("Something Really Really big happened in Usercontrol!!");
}
You will need to bind the usercontrol event in form designer, and in control, instead of button1_click, make the OnSomeThingBigHappened(e);
call where the event will occur