hiding properties or methods in inherited class

  • Thread starter Thread starter Smokey Grindle
  • Start date Start date
S

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!
 
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 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?
 
Smokey Grindle said:
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.
 
Hello Smokey,

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

-Boo
 
Smokey Grindle said:
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
 
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
 
"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.
 
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
 
Cor Ligthert said:
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.
 
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
 
Back
Top