sasikumar

sasikumar

  • NA
  • 15
  • 0

How to subscribe an event from UserControl with Additional parameters?

Nov 11 2011 6:03 AM
Hi,

I've a form frmMain.cs, in which I've added a UserControl ucTest.cs. In the usercontrol, I've added a button click event, in which I'm populating a DataSet ds.

Now I need this dataset to be used on the frmMain.cs for manipulation. How do I pass the dataset ds which was updated in the click event of UserControl back to the frmMain.cs ?

I tried declare a delegate (i'm totally new to delegates) in the UserControl for this, as below --

public delegate Boolean EventHandler(object sender, EventArgs args, DataSet ds);
public event EventHandler evntExecute = delegate {};


In the frmMain.cs, I've added a EventHandler function as below --

public Boolean evntExecute_Handler(object sender, EventArgs e, DataSet ds)
{
        // code using the Dataset ds values
}

Now how do I exactly subscribe this event in the frmMain.cs ?

Thanks.

Answers (3)