We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Catch events arrived from another object

How can I catch events of the object if do like ,f.e: class MyClass{ Event1(); Event2(); ..... } After declaration of MyClass write anywhere in the Main function public static void Main(){ MyClass c = new MyClass(); MyClass c_new; c_new = c; //????? /*After this catch events which arrive to object 'c' in the object 'c_new' How can I do this, if this is possible in general?*/ }

1 Reply

RP Ramesh Praveen Syncfusion Team July 9, 2003 03:53 AM

Actually c and c_new are referring to the same object. And to listen to events fired by this object, you do this: c.Event1 += new EventHandler(this.MyHandler); //Also define MyHandler in your class: private void MyHandler(object sender, EventArgs e) { ... } -Praveen

Loader.
Live Chat Icon For mobile
Up arrow icon