Home All Groups Group Topic Archive Search About

hiding properties or methods in inherited class

Author
24 Jul 2006 8:13 PM
Smokey Grindle
i want to inherit the list view class, but in the inherited class, hide the
Header style property and the view property (basically its a detailed list
with always clickable headers) how do I keep the base class properties from
showing up in the inherited class when people change its properties in the
IDE? thanks!

Author
24 Jul 2006 8:33 PM
GhostInAK
Hello Smokey,

override (or shadow) the properties and change their scope.  (hint: private
or friend scope properties will not be exposed to the public interface)

-Boo

Show quoteHide quote
> i want to inherit the list view class, but in the inherited class,
> hide the Header style property and the view property (basically its a
> detailed list with always clickable headers) how do I keep the base
> class properties from showing up in the inherited class when people
> change its properties in the IDE? thanks!
>
Author
24 Jul 2006 8:54 PM
Smokey Grindle
I thought you coudnt change the scope qualifier of an override though, I
guess shadows is the way to go then since it does allow changing of the
scope qualifier, am I thinking correctly?

Show quoteHide quote
"GhostInAK" <ghosti***@gmail.com> wrote in message
news:%23noamB2rGHA.1140@TK2MSFTNGP05.phx.gbl...
> Hello Smokey,
>
> override (or shadow) the properties and change their scope.  (hint:
> private or friend scope properties will not be exposed to the public
> interface)
>
> -Boo
>
>> i want to inherit the list view class, but in the inherited class,
>> hide the Header style property and the view property (basically its a
>> detailed list with always clickable headers) how do I keep the base
>> class properties from showing up in the inherited class when people
>> change its properties in the IDE? thanks!
>>
>
>
Author
24 Jul 2006 9:26 PM
GhostInAK
Hello Smokey,

You are absolutely correct.  Shadows would be your only option in this scenario
then.

-Boo

Show quoteHide quote
> I thought you coudnt change the scope qualifier of an override though,
> I guess shadows is the way to go then since it does allow changing of
> the scope qualifier, am I thinking correctly?
>
> "GhostInAK" <ghosti***@gmail.com> wrote in message
> news:%23noamB2rGHA.1140@TK2MSFTNGP05.phx.gbl...
>
>> Hello Smokey,
>>
>> override (or shadow) the properties and change their scope.  (hint:
>> private or friend scope properties will not be exposed to the public
>> interface)
>>
>> -Boo
>>
>>> i want to inherit the list view class, but in the inherited class,
>>> hide the Header style property and the view property (basically its
>>> a detailed list with always clickable headers) how do I keep the
>>> base class properties from showing up in the inherited class when
>>> people change its properties in the IDE? thanks!
>>>
Author
24 Jul 2006 9:14 PM
Herfried K. Wagner [MVP]
"Smokey Grindle" <nospam@dontspamme.com> schrieb:
>i want to inherit the list view class, but in the inherited class, hide the
>Header style property and the view property (basically its a detailed list
>with always clickable headers) how do I keep the base class properties from
>showing up in the inherited class when people change its properties in the
>IDE? thanks!

Override them and set the appropriate 'Browsable' and 'EditorBrowsable'
attributes.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
24 Jul 2006 9:29 PM
Jim Wooley
> "Smokey Grindle" <nospam@dontspamme.com> schrieb:
>
>> i want to inherit the list view class, but in the inherited class,
>> hide the Header style property and the view property (basically its a
>> detailed list with always clickable headers) how do I keep the base
>> class properties from showing up in the inherited class when people
>> change its properties in the IDE? thanks!
>>
> Override them and set the appropriate 'Browsable' and
> 'EditorBrowsable' attributes.
>
Of course, this doesn't keep the developer from using the base methods. They
just don't see them in the IDE with intellisense. What you are doing however
is breaking a fundamental tenant of OOP. Consider if your implementing class
really "IS-A" type of the inherited class. If not, you may be better off
using containment rather than inheritance.

Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx
Author
25 Jul 2006 12:43 AM
Smokey Grindle
What exactly is containment? What im doing is extending the functionality of
a list view but I dont want any one to inherit it and change it after this
point


Show quoteHide quote
"Jim Wooley" <jimNOSPAMwooley@hotmail.com> wrote in message
news:24f81e8f72c18c87d5ddd167ad3@msnews.microsoft.com...
>> "Smokey Grindle" <nospam@dontspamme.com> schrieb:
>>
>>> i want to inherit the list view class, but in the inherited class,
>>> hide the Header style property and the view property (basically its a
>>> detailed list with always clickable headers) how do I keep the base
>>> class properties from showing up in the inherited class when people
>>> change its properties in the IDE? thanks!
>>>
>> Override them and set the appropriate 'Browsable' and
>> 'EditorBrowsable' attributes.
>>
> Of course, this doesn't keep the developer from using the base methods.
> They just don't see them in the IDE with intellisense. What you are doing
> however is breaking a fundamental tenant of OOP. Consider if your
> implementing class really "IS-A" type of the inherited class. If not, you
> may be better off using containment rather than inheritance.
>
> Jim Wooley
> http://devauthority.com/blogs/jwooley/default.aspx
>
>
Author
25 Jul 2006 3:53 AM
Michael D. Ober
"containment" is where instead of inheriting your base class, you create a
private variable of the base class type and then explicitely expose, via
your code, the methods and properties of the base class.  As far as
violating basic OOP principles - it doesn't in that sometimes you need to
control specific properties and methods of the base class in your derived
class.

Mike Ober.

Show quoteHide quote
"Smokey Grindle" <nospam@nospam.net> wrote in message
news:uhMsiN4rGHA.4004@TK2MSFTNGP02.phx.gbl...
> What exactly is containment? What im doing is extending the functionality
of
> a list view but I dont want any one to inherit it and change it after this
> point
>
>
> "Jim Wooley" <jimNOSPAMwooley@hotmail.com> wrote in message
> news:24f81e8f72c18c87d5ddd167ad3@msnews.microsoft.com...
> >> "Smokey Grindle" <nospam@dontspamme.com> schrieb:
> >>
> >>> i want to inherit the list view class, but in the inherited class,
> >>> hide the Header style property and the view property (basically its a
> >>> detailed list with always clickable headers) how do I keep the base
> >>> class properties from showing up in the inherited class when people
> >>> change its properties in the IDE? thanks!
> >>>
> >> Override them and set the appropriate 'Browsable' and
> >> 'EditorBrowsable' attributes.
> >>
> > Of course, this doesn't keep the developer from using the base methods.
> > They just don't see them in the IDE with intellisense. What you are
doing
> > however is breaking a fundamental tenant of OOP. Consider if your
> > implementing class really "IS-A" type of the inherited class. If not,
you
> > may be better off using containment rather than inheritance.
> >
> > Jim Wooley
> > http://devauthority.com/blogs/jwooley/default.aspx
> >
> >
>
>
Author
25 Jul 2006 5:49 AM
Cor Ligthert [MVP]
Smokey,

You cannot hide properties from the base class showing up in the IDE.

You can see the same with some standard control classes where some of the
properties don't do anything.

Direct from my mind, the background in the picturebox is one of those but
there are many more.

It does not helps, however maybe is it helpful to know.

Cor


Show quoteHide quote
"Smokey Grindle" <nospam@dontspamme.com> schreef in bericht
news:OsXIZ31rGHA.4884@TK2MSFTNGP03.phx.gbl...
>i want to inherit the list view class, but in the inherited class, hide the
>Header style property and the view property (basically its a detailed list
>with always clickable headers) how do I keep the base class properties from
>showing up in the inherited class when people change its properties in the
>IDE? thanks!
>
Author
25 Jul 2006 10:21 AM
Herfried K. Wagner [MVP]
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb:
> You cannot hide properties from the base class showing up in the IDE.

You can actually hide overridable properties (and other properties too
IIRC), but you cannot prevent them from being accessed.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
25 Jul 2006 10:31 AM
Cor Ligthert [MVP]
Herfried,

The way you showed I have tried in the past with no success.

I can be wrong of course, seriously. But it was not one time, while in the
standard controls there are lot of things which would be hidden in the IDE
property box if that was possible in my idea.

Cor

Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schreef in bericht
news:%23tn8HQ9rGHA.4272@TK2MSFTNGP03.phx.gbl...
> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb:
>> You cannot hide properties from the base class showing up in the IDE.
>
> You can actually hide overridable properties (and other properties too
> IIRC), but you cannot prevent them from being accessed.
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://classicvb.org/petition/>