Get events bound to the control

Source: Internet
Author: User
// Obtain the information of all events defined by the textbox class. propertyinfo Pi = (typeof (textbox )). getproperty ("Events", bindingflags. instance | bindingflags. nonpublic); // obtain the event handler list of textbox1 of the textbox object eventhandlerlist EHL = (eventhandlerlist) Pi. getvalue (this. textbox1, null); // obtain the field information of the control class textchanged event fieldinfo = (typeof (Control )). getfield ("eventtext", bindingflags. static | bindingflags. nonpublic); // use the field information of the obtained click event to match the event handler list of the textbox1 object and obtain the delegate object of the textbox1 object textchanged event. // The event is defined by the delegate, in C #, a multicast delegate can be bound to multiple Event Handlers. when an event occurs, these event handlers are executed in sequence // Therefore, the delegate object has a getinvocationlist method, used to obtain all event handlers bound to this delegate. Delegate d = EHL [fieldinfo. getvalue (null)];


Get events bound to the control

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: 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.