In a WinForm project, it is difficult to use the window control directly except for classes other than the window class, because the control object is not static (static), but it cannot go to the designer to modify the properties of the space. There is also a case where the value of the control needs to be changed automatically. You need to use the event in this case
Cases:
Arbitrarily declare a delegate at the appropriate location in the project, the parameter type is consistent with the control
Public Delegate void Testdelegate (string msg);
Declare the event, and define the event accessor:
Public Event testdelegate testevent{{ add { + = value; } Remove { = value; }}
Methods for calling an event-bound control asynchronously:
TestEvent + = Txtmethod; Public void Txtmethod (string msg)// The specific method of the asynchronous invocation of the control {delegate( String m) { + = m; } Txtcontent.invoke (Del, msg);}
This TXT control can output the value of MSG when the event testevent is triggered:
string " This is a Test " ; if null) // Triggering events TestEvent (msg);
The first time you study, you have to practise more.
Yes, that's what you learned from Zhang Ziyang's network programming article: http://www.cnblogs.com/JimmyZhang/archive/2008/09/07/1286299.html
Vegetable Chicken Learning Notes Asynchronous invocation of the--winform control