Classes will always have the methods and properties they were created with. You cannot hide these from code but you can hide them from the eyes of your users if you know what you're doing.
In the case of a class that is examined at design-time by the property grid you can hide classes by creating a designer for your class and overriding the PreFilterProperties or PostFilterProperties methods. These take the list of properties obtained by reflection and remove enable you to add or rmove property descriptors. This is how the Browsable attribute works to enable certain properties to be visible at design time.
The trick of overriding the class and marking a property as browseable or not is also a possibility for design-time usage but is IMO not quite so desirable.
If you're code presents properties in some other way at runtime, perhaps through the property grid or some other form of reflection, you can make your class implement ICustomTypeDescriptor. This interface enables you to preemptively filter properties and can be used at runtime without a designer.
--
Bob Powell [MVP]
Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"Paul Wu" <pw*@spam.encorecredit.com> wrote in message news:un*************@TK2MSFTNGP15.phx.gbl...
Is there a way to constract a derived class that hides certain public members of a base class ?
With the following code, a class that derives from DerivedClass can still see the member "Name" in the base class. Can anyone provide me with an example that will do what I need?
Public Class BaseClass
Private mName As String = "Bob"
Public Overridable Function Name() As String
Name = mName
End Function
End Class
Public Class DerivedClass : Inherits BaseClass
Private Shadows Function Name() As String
Name = "Joe"
End Function
End Class
--------------------------------
Thanks,
Paul Wu