Hello MC,
As for hidding a property(function) in base class, so far the .net
framework programming language (C# and VB.NET) doesn't provide a direct
means to do this. What you can get is use a "new" keyword (in C#) to
redefine a property(method) and them use some .NET specific attribute to
decorate it.
For example ,you can use the "BrowsableAttribute" to make your control's
"Text" property invisible in IDE designer's property windows. You can also
use "ObsoleteAttribute" to make the property unusable(report error at
compile time if you try using it). e.g.
======================
public class MyTextBox :TextBox
{
public MyTextBox()
{
}
[Obsolete("This property is no longer used in this control", true)]
[Browsable(false)]
public new string Text
{
get { return "not used..."; }
}
}
===========================
#ObsoleteAttribute Class
http://msdn2.microsoft.com/en-us/library/system.obsoleteattribute.aspx
#BrowsableAttribute Class
http://msdn2.microsoft.com/en-us/library/system.componentmodel.browsableattr
ibute.aspx
Hope this helps some.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
mc - 12 Mar 2007 10:20 GMT
Over the weekend I'd spotted the EditorBrowsable and Browsable
attributes, but I've not come across the Obsolete attribute. That along
with the new keyword does the job nicely.
It's been pointed out elsewhere that someone can cast my control as a
TextBox and still access the property.
Thank you for not launching into a philosophical OO rant about how bad
it is to try and remove an inherited property!
Thanks
MC
> Hello MC,
>
[quoted text clipped - 71 lines]
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
Steven Cheng[MSFT] - 12 Mar 2007 11:29 GMT
You're welcome ;-)
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead