473,408 Members | 1,845 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Hiding inherited members

I've created a class derived from NativeWindow. The public methods are
visible to consumers of my class and I don't wish them to be. How does one
hide those members?

Best

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.500 / Virus Database: 298 - Release Date: 7/10/2003
Nov 13 '05 #1
9 7503
I was actually going to ask the same question. I'll give
you an example though.

If you look at the TrackBar control, there is no Text
property because there is no text rendered on the
control. The TrackBar inherits from the Control class,
which does have a Text property.

From what I understand, using the keyword new is supposed
to allow you to replace an inherited function with your
own. This doesn't work if you change the scope.

If I remember correctly, changing the scope does work in
VB with the Shadows keyword. I would assume that C#
would have some way to do it.
-----Original Message-----
I've created a class derived from NativeWindow. The public methods arevisible to consumers of my class and I don't wish them to be. How does onehide those members?

Best

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).Version: 6.0.500 / Virus Database: 298 - Release Date: 7/10/2003

.

Nov 13 '05 #2
Mike M <mi*********@bcbskc.com> wrote:
I was actually going to ask the same question. I'll give
you an example though.

If you look at the TrackBar control, there is no Text
property because there is no text rendered on the
control.


But TrackBar *does* have a Text property. I'm not sure why it's not
document, but it *does* exist:

using System;
using System.Windows.Forms;

public class Test
{
static void Main()
{
TrackBar tb = new TrackBar();
tb.Text="hello";
}
}

compiles fine.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 13 '05 #3
Then it must be hidden. It doesn't show up in the
intelliSense, which is good enough to avoid confusion.
The BrowsableAttribute just makes it so that it doesn't
show up in the property browser. I was wondering if the
ObsoleteAttribute might do it, but I it doesn't look like
it.

-----Original Message-----
Mike M <mi*********@bcbskc.com> wrote:
I was actually going to ask the same question. I'll give you an example though.

If you look at the TrackBar control, there is no Text
property because there is no text rendered on the
control.
But TrackBar *does* have a Text property. I'm not sure

why it's notdocument, but it *does* exist:

using System;
using System.Windows.Forms;

public class Test
{
static void Main()
{
TrackBar tb = new TrackBar();
tb.Text="hello";
}
}

compiles fine.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
.

Nov 13 '05 #4
Mike M <mi*********@bcbskc.com> wrote:
Then it must be hidden. It doesn't show up in the
intelliSense, which is good enough to avoid confusion.
The BrowsableAttribute just makes it so that it doesn't
show up in the property browser. I was wondering if the
ObsoleteAttribute might do it, but I it doesn't look like
it.


I believe you're looking for EditorBrowsableAttribute.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 13 '05 #5
Awesome. Thanks. You wouldn't happen to know where I
can find a nice, neat list of ALL the attributes, would
you? I found one in help, but either I'm blind or it
wasn't in the list.
-----Original Message-----
Mike M <mi*********@bcbskc.com> wrote:
Then it must be hidden. It doesn't show up in the
intelliSense, which is good enough to avoid confusion. The BrowsableAttribute just makes it so that it doesn't show up in the property browser. I was wondering if the ObsoleteAttribute might do it, but I it doesn't look like it.


I believe you're looking for EditorBrowsableAttribute.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
.

Nov 13 '05 #6
Mike M <mi*********@bcbskc.com> wrote:
Awesome. Thanks. You wouldn't happen to know where I
can find a nice, neat list of ALL the attributes, would
you? I found one in help, but either I'm blind or it
wasn't in the list.


If you look up System.Attribute in MSDN and then expand "Derived
Classes" you'll get the immediately derived ones. It's in that list -
but it's a pretty big list!

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 13 '05 #7
Thanks
-----Original Message-----
Mike M <mi*********@bcbskc.com> wrote:
Awesome. Thanks. You wouldn't happen to know where I
can find a nice, neat list of ALL the attributes, would you? I found one in help, but either I'm blind or it
wasn't in the list.
If you look up System.Attribute in MSDN and then

expand "DerivedClasses" you'll get the immediately derived ones. It's in that list -but it's a pretty big list!

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
.

Nov 13 '05 #8
Thanks, I was leaning in that direction after spelunking around MSDN. Man
I've got much to learn about object oriented design principles. Have any
recomendations for neophytes?
"Jon Skeet" <sk***@pobox.com> wrote in message
news:MP************************@news.microsoft.com ...
Troy Hilbert <th******@spamfree.hotmail.com> wrote:
I've created a class derived from NativeWindow. The public methods are
visible to consumers of my class and I don't wish them to be. How does one hide those members?


You don't. That would violate Liskov's Substitutability Principle, for
a start. I suggest you have a NativeWindow as a field within your class
rather than deriving from it.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.500 / Virus Database: 298 - Release Date: 7/10/2003
Nov 13 '05 #9
Troy Hilbert <th******@spamfree.hotmail.com> wrote:
Thanks, I was leaning in that direction after spelunking around MSDN. Man
I've got much to learn about object oriented design principles. Have any
recomendations for neophytes?


Write lots of code, work out what's unpleasant about it, and learn from
that. I dare say there are plenty of books that would help out (the
Gang of Four "Design Patterns" book, for instance) but experience is
the best teacher. There's nothing like doing it wrong to teach you to
do it right :)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 13 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: thechaosengine | last post by:
Hi all, Is there a way to hide a member in a subclass that has been inherited from a base class? Lets leave aside any issues regarding whether its a good idea for a moment. Here's an example...
7
by: Tron Thomas | last post by:
Under the right compiler the following code: class Base { public: virtual void Method(int){} }; class Derived: public Base {
10
by: Jacob | last post by:
Is there a way to make a property of an inherited class invisible to the programmer? I know that using the keyword "new" allows you to create another property in the place of the existing one, but...
6
by: Microsoft | last post by:
Base class: class AssetBase { string _clli; public string CLLI { get
4
by: Dan | last post by:
I have a need to make a set of classes that all share the same public methods, some implementation and some data. So, I made an abstract base (BaseClass) with an interface (IBaseClass) and a...
7
by: Dennis | last post by:
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...
7
by: OpticTygre | last post by:
If I have a Class "B" that Inherits Class "A", and my application uses class "B", is there a way that I can keep from exposing properties, subs, and events in the Class "A" base class from the...
14
by: lovecreatesbea... | last post by:
Could you tell me how many class members the C++ language synthesizes for a class type? Which members in a class aren't derived from parent classes? I have read the book The C++ Programming...
9
by: Torben Laursen | last post by:
Hi I have a class that I use in Excel to define some custom functions. The problem that I have is that the class also has some building functions that for some reason is there: ToString...
0
by: Keenath | last post by:
Is it possible for an inheritor class to hide one of its parents' public functions? I don't mean just replacing the functionality, but to make it such that "Child.X()" is not a valid call, even...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.