views:

1253

answers:

1

I've create a WinForms control that inherits from System.Windows.Forms.UserControl...I've got some custom events on the control that I would like the consumer of my control to be able to see. I'm unable to actually get my events to show up in the Events tab of the Properties window during design time. This means the only way to assign the events is to programmatically write

myUserControl.MyCustomEvent += new MyUserControl.MyCustomEventHandler(EventHandlerFunction);

this is fine for me I guess but when someone else comes to use my UserControl they are not going to know that these events exist (unless they read the library doco...yeah right). I know the event will show up using Intellisense but it would be great if it could show in the properties window too.

+9  A: 

Make sure your events are exposed as public. For example...

[Browsable(true)]
public event EventHandler MyCustomEvent;
Phil Wright
It's a public custom event handler and the event handler type is a public delegate...there is nothing functionally wrong...the events work and fire in the correct way, it's purely a design time issue.
Michael Prewecki
Aha, make sure the event handler definition is always declared as public otherwise it will not be visible.
Phil Wright
As I said it is public...
Michael Prewecki
I've also just changed it from my custom event handler type to a simple EventHandler and it still doesn't show in the Events tab of Properties Window
Michael Prewecki
I've update the answer to show the extra browser attribute you can try
Phil Wright
That's appears to be the one...Thanks Phil...
Michael Prewecki