Hiding Properties of Inheirited Classes

G

Guest

I have a class named myclass that inheirits from "baseclass". There is a
property of "baseclass" that I don't want exposed in the IDE. The MSDN
documentation says"

"A derived type can hide an inherited member by defining a new member with
the same signature. This might be done to make a previously public member
private or to define new behavior for an inherited method that is marked as
final. "

However, this does not hide the property. For example, in my code;

dim c as myclass = new myclass

when I type c. the designer shows all the properties and methods and it
includes the property that I have made private in myclass.

Is there anyway that I can fix this?
 
C

Cor Ligthert

Dennis,

You see that with the picturebox as well where in my opinion the
backgroundcolor is shadowed (hidden). When you shadows it and make it
private as the documentation says, than is my expirience that it takes the
property from the base class.

I have searched on Google for that and the only thing I found was setting
<browsable> to false, however that does not work as well in the IDE itself.

This does not help you hoever shows that you are not the only one who is
looking for a way to do this.

I hope that it helps in that way?

Cor
 
H

Herfried K. Wagner [MVP]

Dennis said:
I have a class named myclass that inheirits from "baseclass". There is a
property of "baseclass" that I don't want exposed in the IDE. The MSDN
documentation says"

"A derived type can hide an inherited member by defining a new member with
the same signature. This might be done to make a previously public member
private or to define new behavior for an inherited method that is marked
as
final. "

However, this does not hide the property. For example, in my code;

dim c as myclass = new myclass

when I type c. the designer shows all the properties and methods and it
includes the property that I have made private in myclass.

You cannot completely remove the method -- this would stand against the
concepts of inheritance and extension by deriving. All you can do is
overriding (or maybe direclty shadowing) the method and specifying
'Browsable' and/or 'EditorBrowsable' attributes with appropriate value on
the member (these attributes are defined in the 'System.ComponentModel'
namespace).
 
G

Guest

Thanks for answers. Disappointing that VB.Net doesn't do what Microsoft says
it will.
 
G

Guest

Herfried brings up the attribute that you need in his reponse. The
EditorBrowsable attribute allows for 'hiding' a member from the auto list
feature in the IDE. You can select Never, Advanced, or Always. The Never
option will hide this method even if the IDE Setting under Tools->Options -
Text Editor All Languages (or individual language) shows the Hide advanced
members as unchecked.

One quirky thing about the EditorBrowsable setting is if a base class has
the method as browsable, and the derived does not, it will show the member
from the base class. This is confirmed by changing the case on the derived
class overridden or shadowed member. It will show the method character
casing from the base class, which has the browsable attribute allowing for
visibility in the auto list. This is strange, and a bit annoying.

The Browsable attribute allows for hiding within the design view property
window in the case of a custom control.

As far as the original article, 'hide' is the term that Microsoft uses in
this instance to specify that the method implementation is hidden when using
the derived class. The second part of the statement makes reference to this,
as it allows for changing the availability of the method from public to
private, or having new behavior. The method name itself was not hidden.

Hope this helps all.
 

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