Override Event

  • Thread starter Thread starter Ryan Joseph So
  • Start date Start date
R

Ryan Joseph So

Hi,

Is it possible to override an event replacing its EventArgs w/ my own
event? like
this is native event
protected override void OnDropDownClosed(EventArgs e)
{
//code goes here...
}

I created my own EventArgs so I could replace the one on top. Its called
DropDownClosed_EventHandler. So it should look like this.
protected override void OnDropDownClosed(DropDownClosed_EventHandler e)
{
//code goes here...
}
but it doesn't accept it. If i use this code.
public event DropDownClosed_EventHandler DropDownClosed;

DropDownClosed_EventArgs args = new DropDownClosed_EventArgs();
DropDownClosed(this, args);
after i compiled it, it shows 2 DropDownClosed event one is mine and the
other is native. Is there a way to override the original event so i
could use its name at least to create my own event?
 
Hi Ryan,

Changing the argument list is rather overloading than overriding and I am
not sure overloading is supported for delegates. So I'd just create a second
event with my own EvenArgs type, and I would even name it something like
DropDownClosedEx.
 
Thanks Dmitriy but I still have one question. Is it possible to hide the
native event so only my event would show up when i compiled the project?
 
Back
Top