By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,216 Members | 1,443 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,216 IT Pros & Developers. It's quick & easy.

Hiding event?

P: n/a
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.

--
David Veeneman
Foresight Systems
Apr 4 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"David Veeneman" <da****@nospam.com (domain is my last name)> wrote in
message news:ux**************@TK2MSFTNGP14.phx.gbl...
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.

--
David Veeneman
Foresight Systems

Apr 4 '06 #2

P: n/a
> 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!
Apr 4 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.