I have a form and a clsevent class,
An event is registered in the form.
A delegate + event is defined in the clsevent class, and an event is thrown. But why cannot I obtain this event in the form ??
Later, I modified the event defined in the clsevent class to static, and the form can be obtained?
Clsevent class public class clsevent {Public Delegate void showsometing1 (string strtxtbox); public static event showsometing1 btnclick1; private string _ strcontent; Public String strcontent {get {return _ strcontent ;} set {// when the attribute is changed, the event _ strcontent = value is triggered; // The event is triggered in the event issuer. If (btnclick1! = NULL) {btnclick1 (_ strcontent );}}}
Form1_Load
clsEvent m_clsEvent = new clsEvent();
// Form registers the event m_clsevent. btnclick1 + = new m_clsevent. showsometing1 (textboxchange) to the class)
Private void button#click (Object sender, eventargs e) {// modify attributes to stimulate events. M_clsevent. strcontent = This. textbox1.text;} public void textboxchange (string strcontent) {this.txt class. Text = strcontent ;}