Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Override inherited delegates???

Override inherited delegates???

Scheduled Pinned Locked Moved C#
question
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lsugirljte
    wrote on last edited by
    #1

    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

    L S L 3 Replies Last reply
    0
    • L lsugirljte

      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

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      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

      L 1 Reply Last reply
      0
      • L 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

        L Offline
        L Offline
        lsugirljte
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • L lsugirljte

          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

          S Offline
          S Offline
          S Senthil Kumar
          wrote on last edited by
          #4

          You could try using the new keyword and redefine the event in your myMultiGridView class. For example

          class 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 own RowUpdating event. Unfortunately, this only works if the client uses your class to subscribe to events. For example

          GridView g = new GridView();
          g.RowUpdating += ... // Won't work

          MyMultiGridView g = new MyMultiGridView();
          g.RowUpdating += ... // This will work.

          Regards Senthil [MVP - Visual C#] _____________________________ My Blog | My Articles | My Flickr | WinMacro

          1 Reply Last reply
          0
          • L lsugirljte

            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

            L Offline
            L Offline
            lsugirljte
            wrote on last edited by
            #5

            I found that this worked fine. base.RowUpdating -= new GridViewUpdateEventHandler(base.PreUpdate);

            Thanks, Jessica

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups