Inheritence question

B

Bob Shafer

I am inheriting from a picturebox and would like to hide
some of the public properties and methods. Can this be
done. Thanks! Bob.
 
N

NetPointer

Instead of Inheritence, you can use contentment, aggregation COM based
inheritence trick..
u create all the same named properties in your class, and then create
picturebox internally..and expose its property via your class properties.

Regards,
NetPointer
 
H

Herfried K. Wagner [MVP]

J

Joe White

You can't make properties go away in the descendant, but you can tell
the Property Grid not to show them. You can do this by overriding (or
redeclaring if it's not virtual) the property in your descendant, and
tagging it with the [Browsable(false)] attribute. This is what the .NET
framework does, for example, to make the BackgroundImage property
unavailable for the TextBox control -- the property exists, but the
Property Grid has been instructed not to show it.

There is no way to make a method go away in a descendant; for that, or
to make a property truly unavailable in your class (i.e., not accessible
even through code), you'll need to write a wrapper instead of a subclass.
 

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