EventHandler delegate with custom delegate

Source: Internet
Author: User

http://blog.csdn.net/uuxyz/article/details/7175248

EventHandler delegate with custom delegate

Custom Delegate:

//1. Public Delegate voidUcsavedeventhanler (BOOLissuccess); //2. Public EventUcsavedeventhanler onucsaved; //3.UcEditor1 (user control). onucsaved+=NewUcsavedeventhanler (uceditor1_onucsaved); voidUceditor1_onucsaved (BOOLissuccess) {      //TODO:}

EventHandler Commission:

//2.1. Public EventEventHandler onucsaved;//2.2. Public classsavedeventargs:eventargs{ PublicSavedeventargs (BOOLissuccess) { This. issuccess=issuccess; }     Public BOOLissuccess; }//end of class Savedeventargs//3.UcEditor1 (user control). onucsaved+=NewEventHandler (uceditor1_onucsaved);voidUceditor1_onucsaved (ObjectSender,eventargs e) {      //TODO:}

 

1:eventhandler is actually a special delegate, it is made up of. NET is a predefined delegate, and its form is fixed . The definition of EventHandler is similar to the following:
delegate void EventHandler(Object Sender,eventargs e);
such as the Click event

New EventHandler (But_click); void But_click (object  sender, EventArgs e) {    //Todo}

2: When using EventHandler, the return value of the handler function must be of type void, while using deleagate does not have this restriction.

3:delegate is equivalent to a pointer to a function that is used to bind the function return value and the parameter list to conform to the requirements of the delegate declaration.

EventHandler delegate with custom delegate

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.