hiding properties or methods in inherited class

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!
 
G

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
 
S

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?
 
H

Herfried K. Wagner [MVP]

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.
 
G

GhostInAK

Hello Smokey,

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

-Boo
 
J

Jim Wooley

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
 
S

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
 
M

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.
 
C

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
 
H

Herfried K. Wagner [MVP]

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.
 
C

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top