Override inherited delegates???
-
Can you override inherited delegates? If so, how? I have a control that inherits from GridView (i.e. myGridView). It has a deleglate to handle some custom stuff. public PBGridView() { RowUpdating += new GridViewUpdateEventHandler( PreUpdate ); } I have another control that inherits from myGridView (i.e. myMultiGridView). I want to have it's own RowUpdating and skip the inherited one. How do I override it or "remove" it from myMultiGridView?? or do I have to edit myGridView to handle where it's getting called from? I would like to take care of it in myMultiGridView (lowest inherited level). Thanks, Jessica
-
Can you override inherited delegates? If so, how? I have a control that inherits from GridView (i.e. myGridView). It has a deleglate to handle some custom stuff. public PBGridView() { RowUpdating += new GridViewUpdateEventHandler( PreUpdate ); } I have another control that inherits from myGridView (i.e. myMultiGridView). I want to have it's own RowUpdating and skip the inherited one. How do I override it or "remove" it from myMultiGridView?? or do I have to edit myGridView to handle where it's getting called from? I would like to take care of it in myMultiGridView (lowest inherited level). Thanks, Jessica
lsugirljte wrote:
Can you override inherited delegates? If so, how?
They hide that information in the documentation[^]
The OnRowUpdating method also allows derived classes to handle the event without
attaching a delegate. This is the preferred technique for handling the event in a derived class.led mike
-
lsugirljte wrote:
Can you override inherited delegates? If so, how?
They hide that information in the documentation[^]
The OnRowUpdating method also allows derived classes to handle the event without
attaching a delegate. This is the preferred technique for handling the event in a derived class.led mike
Thanks for the help but I'm worried about this part. "Notes to Inheritors When overriding OnRowUpdating in a derived class, be sure to call the base class's OnRowUpdating method so that registered delegates receive the event. " I don't want to call the base class's OnRowUpdating method because it has code that won't work with my inherited class. Thanks, Jessica
-
Can you override inherited delegates? If so, how? I have a control that inherits from GridView (i.e. myGridView). It has a deleglate to handle some custom stuff. public PBGridView() { RowUpdating += new GridViewUpdateEventHandler( PreUpdate ); } I have another control that inherits from myGridView (i.e. myMultiGridView). I want to have it's own RowUpdating and skip the inherited one. How do I override it or "remove" it from myMultiGridView?? or do I have to edit myGridView to handle where it's getting called from? I would like to take care of it in myMultiGridView (lowest inherited level). Thanks, Jessica
You could try using the
new
keyword and redefine the event in yourmyMultiGridView
class. For exampleclass GridView
{
public event RowUpdatingDelegate RowUpdating;
}class MyMultiGridView : GridView
{
public new event RowUpdatingDelegate RowUpdating;
}Now clients who subscribe to MyMultiGridView's
RowUpdating
event will not get notified when the base class fires the event, so you get your ownRowUpdating
event. Unfortunately, this only works if the client uses your class to subscribe to events. For exampleGridView g = new GridView();
g.RowUpdating += ... // Won't workMyMultiGridView g = new MyMultiGridView();
g.RowUpdating += ... // This will work.Regards Senthil [MVP - Visual C#] _____________________________ My Blog | My Articles | My Flickr | WinMacro
-
Can you override inherited delegates? If so, how? I have a control that inherits from GridView (i.e. myGridView). It has a deleglate to handle some custom stuff. public PBGridView() { RowUpdating += new GridViewUpdateEventHandler( PreUpdate ); } I have another control that inherits from myGridView (i.e. myMultiGridView). I want to have it's own RowUpdating and skip the inherited one. How do I override it or "remove" it from myMultiGridView?? or do I have to edit myGridView to handle where it's getting called from? I would like to take care of it in myMultiGridView (lowest inherited level). Thanks, Jessica
I found that this worked fine. base.RowUpdating -= new GridViewUpdateEventHandler(base.PreUpdate);
Thanks, Jessica