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. Dear Inheritance - A question for you

Dear Inheritance - A question for you

Scheduled Pinned Locked Moved C#
questionoop
4 Posts 4 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.
  • G Offline
    G Offline
    Gulfraz Khan
    wrote on last edited by
    #1

    Is it possible to hide any public method or public property of the base class when inheriting that class. If yes, then how? Infact I am creating a custom control by inheriting a ScrollableControl and I don't want to show the AutoScroll property to user of my control (developer). Thanks -- modified at 12:39 Thursday 10th November, 2005

    L R 2 Replies Last reply
    0
    • G Gulfraz Khan

      Is it possible to hide any public method or public property of the base class when inheriting that class. If yes, then how? Infact I am creating a custom control by inheriting a ScrollableControl and I don't want to show the AutoScroll property to user of my control (developer). Thanks -- modified at 12:39 Thursday 10th November, 2005

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      Gulfraz Khan wrote:

      Is it possible to hide any public method or public property of the base class when inheriting that class.

      No xacc.ide-0.1-rc2 released! Download and screenshots

      C 1 Reply Last reply
      0
      • L leppie

        Gulfraz Khan wrote:

        Is it possible to hide any public method or public property of the base class when inheriting that class.

        No xacc.ide-0.1-rc2 released! Download and screenshots

        C Offline
        C Offline
        Colin Angus Mackay
        wrote on last edited by
        #3

        That's a good short answer there. Direct and to the point!


        My: Blog | Photos "Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious

        1 Reply Last reply
        0
        • G Gulfraz Khan

          Is it possible to hide any public method or public property of the base class when inheriting that class. If yes, then how? Infact I am creating a custom control by inheriting a ScrollableControl and I don't want to show the AutoScroll property to user of my control (developer). Thanks -- modified at 12:39 Thursday 10th November, 2005

          R Offline
          R Offline
          Robert Rohde
          wrote on last edited by
          #4

          Absolutely hiding isn't possible. But there are a few tricks to accomplish what you are trying to do. Have a look at this snippet:

          [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
          public override bool AutoScroll
          {
          get { return base.AutoScroll; }
          set {}
          }

          - It will disable Intellisense in the designer. - It will hide it from the properties window. - It won't allow any changes to this property Note that if a user of your control types yourClass.AutoScroll = false then the compiler won't give any error... but who said that solution was perfect ;). But if you also add the Obsolete attribute then intellisense will at least give him a hint.

          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