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.
Unfortunately, activation email could not send to your email. Please try again.

Adding an event handler to the property page

Thread ID:

Created:

Updated:

Platform:

Replies:

3997 Apr 22,2003 04:52 PM May 9,2003 10:10 AM General Discussion 2
loading
Tags: General Discussion
Sameer
Asked On April 22, 2003 04:52 PM

Hello, I created a custom data grid, with custom table styles et al. I am exposing a event handling delegate as a property, so that the users may hook their own functions to add on to the paint methods. The Property does show up in the property page, however it wont allow me to add anything there. What I am basically asking is, How do I expose a delegate in the property page of a custom control? Thanks, -S

Administrator [Syncfusion]
Replied On May 2, 2003 10:32 AM

i hope this is what you are asking [Category("Property Changed")] public event EventHandler SelectedIndexChange; protected virtual void OnSelectedIndexChange(EventArgs e) { if (SelectedIndexChange != null) { // Invokes the delegates. SelectedIndexChange(this, e); } } and whereever you want to fire the event you put this.OnSelectedIndexChange(new EventArgs());

Sameer
Replied On May 9, 2003 10:10 AM

No, I will try explaining the problem again, maybe i am not sure what i really want ( that is always dangerous ) I have a custom control, which is a data grid. I have a delegate defined within the control, and i want the users to hook their own functions there. From ur example, when we have a combo box, and we need to handle some events, like the selected change, in the property sheet u would look up the event selected index changed and add ur own function there. Similarly I am exposing an event called CellPaint, and I need the user to add their own function. When I expose the delegate from within my control as a public property, it appears on the property sheet, but is uneditable. I am sorry if i am not too clear abt my question. i am still a newbie and pretty much learning the C# lingo thanks for your answer tough. -S > i hope this is what you are asking > > [Category("Property Changed")] > public event EventHandler SelectedIndexChange; > > protected virtual void OnSelectedIndexChange(EventArgs e) > { > if (SelectedIndexChange != null) > { > // Invokes the delegates. > SelectedIndexChange(this, e); > } > } > > and whereever you want to fire the event you put > this.OnSelectedIndexChange(new EventArgs()); >

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;