Saturday, January 28, 2012

Create custom Events and Delegates with c#

when part of user controls logic and part of forms logic need to be executed at one shot ,then user defied events are required.User defined events is called  as Callback procedure.For this we have to follow four steps to develop user defined events
1.create a delegate
2.Create a event wit the help of delegate
3.raise the event (call the event)
4.Define the event (write the body)
note:When developing the control,steps 1,2,&3 need to be fallowed.While using the control step four need to be followed
Hre i will shown an example for how to create events with delagates.In my application i have created a usecontrol and it has the option to load the data in when the ocntrol is loading.For this i have created a page load event .
 Load += new EventHandler(delegate(object PreRenderSender, EventArgs Evt) { if (ViewSet.GetActiveView() != Edit)GiveOutput(); });

protected void SetOutput()
 {
 }

No comments:

Bel