1, what is commissioned, here will not be introduced, If You Want To Know can view blog: http://www.cnblogs.com/xiaoxiaogogo/p/3571494.html
The following describes the events.
First, define the delegate corresponding to the event:
ThreeClickEventDel();
Then it corresponds to the event variable: (in fact, an event is added before the delegate)
ThreeClickEventDel ThreeClickEvent;
After decompilation: A "" and two "and" "Methods
1) private delegation: only the class can be called internally and cannot be called outside the class. The instance of the created class cannot be called. Therefore, events are safe.
Because it is private, you cannot use "=" to assign values to events.
2) because there are "" add and remove ,, therefore, the class instance can perform "+ =" and "-=" on the event to add events and delete events (so the event can be assigned a value outside the class, but cannot be called)
1. Data Type During delegation, but events are data-type variables (and private delegation)
2. The delegate can be called outside the class, but the event cannot be called outside the class through the class instance (because it is a private delegate)
3. Delegates can assign values through "=", "+ =", and "-=", but events can only assign values to events through "+ =" and "-=. (Because the event is a private delegate)
Delegated registration event:
Main( GuoluFang Guolu = Guolu.jingGao = Console.WriteLine( ( i = ; i <; i++ }
Why derivative events:
1. Because an event can only be assigned values through "+ =" and "-=", you can avoid using the "=" value assignment as the delegate (the original event may be rushed out ).
2. Although an event is defined as public, it is compiled into a "private delegate". Therefore, an event can only be called within the class, and the instance of the class cannot be called.
Create a verification control:
Add a UserControl control. The design is as follows:
Write background code:
UserVilidateDel (btnLogin_Click (userName = pwd = MyEventArgs eArgs = eArgs. userName = eArgs. pwd = eArgs. isSuccess = UserViliDating (. txtUserName. backColor =. txtPwd. backColor =. txtUserName. backColor =. txtPwd. backColor = UserName {; Pwd {; IsSuccess {;}Control background code
Add verification controls to the main form:
Background code:
Form1_Load( userVilidateControl1.UserViliDating += userVilidateControl1_UserViliDating( (e.UserName == && e.Pwd == e.IsSuccess = }