Hiding event?

D

David Veeneman

I'm writing a user control that provides its own Validating event. The
control's Validating event passes a custom set of event args, rather than
the CancelEventArgs used by the UserControl's Validating event.

That means I have to hide the UserControl's Validating event with the 'new'
keyword on my own event:

[Browsable(true)]
public new event EventHandler<ValidatingEventArgs<object>> Validating;

Here's my problem: Even though the event is decorated with a Browsable
attribute, the event does not appear in the Event List in the VS.Net
Properties window. I can manually assign an event handler, and the property
works fine. But I'd like to assign the handler using the Properties window.

What do I need to do to get this event to show up in the Properties window?
Thanks.
 
N

Nicholas Paldino [.NET/C# MVP]

David,

Instead of overriding the Validating event, you should use a unique
event name. The reason for this is that other users of your control are
going to expect Validating to do something different.

If you are just trying to augment the information passed in the
Validating event, then why not derive your event args class from
CancelEventHandler and then in your event handlers for the Validating event
for that user control, cast to your specific event args type?

Hope this helps.
 
D

David Veeneman

If you are just trying to augment the information passed in the Validating
event, then why not derive your event args class from CancelEventHandler
and then in your event handlers for the Validating event for that user
control, cast to your specific event args type?

That had never occured to me--thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top