How to override a method in usercontrol?

  • Thread starter Thread starter Tee
  • Start date Start date
T

Tee

Hi,

I have a usercontrol with a overridable/virtual method. On the usercontrol
onload, it will call this method.

Now I have a form that have a few of this usercontrol.
And I want to override the method in each usercontrol, how do I accomplish
this?


Thanks,
Tee
 
Tee said:
Hi,

I have a usercontrol with a overridable/virtual method. On the usercontrol
onload, it will call this method.

Now I have a form that have a few of this usercontrol.
And I want to override the method in each usercontrol, how do I accomplish
this?

public class ChildControl : ParentControl {

public override void MyMethod() {
base.MyMethod();
}

}
 
Tee said:
I'm not inheriting it ...

Any idea?

Overriding is a property of derived classes, so if you're not inheriting it,
AFAIK you can't override it. If you have access to the source of the
controls you could change them to call a delegate instead of the overridable
method, and then make that delegate settable from outside the control. It
would be a pretty nasty solution though.
 
Back
Top