Dear Inheritance - A question for you
-
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
-
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
Gulfraz Khan wrote:
Is it possible to hide any public method or public property of the base class when inheriting that class.
-
Gulfraz Khan wrote:
Is it possible to hide any public method or public property of the base class when inheriting that class.
-
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
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.