473,385 Members | 1,192 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,385 software developers and data experts.

HOW-TO: "Hide" a property of a base class

Folks,

I've created a descendant of ListView, and I would like to be able to
tell it to "hide" two of the base class's properties - how can I
accomplish this?

I know I can add a [Browsable(false)] attribute to the properties to
remove them from the object inspector window - that's not all, though
- I'd like to make them unavailable from code, too.

How do I accomplish this?? If it's possible, that is.....

Thanks!
Marc
================================================== ==============
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
Nov 15 '05 #1
1 4219
Marc Scheuner [MVP ADSI] <m.********@inova.SPAMBEGONE.ch> wrote:
I've created a descendant of ListView, and I would like to be able to
tell it to "hide" two of the base class's properties - how can I
accomplish this?

I know I can add a [Browsable(false)] attribute to the properties to
remove them from the object inspector window - that's not all, though
- I'd like to make them unavailable from code, too.

How do I accomplish this?? If it's possible, that is.....


You can't - and for good reason. It completely violates Liskov's
Substitutability Principle. Further more, it would be trivial to get
round - the caller could just declare his reference variable to be of
the base class type, and then how would the compiler know to stop it?

What you *can* do of course is override the properties (assuming
they're virtual) and throw exceptions in them. That's a pretty nasty
thing to do though.

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

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

Similar topics

0
by: MS | last post by:
Hi, Please does anyone know how I can hide and unhide hidden folders either through theWindows API or a class that does it? Thanks...
1
by: PawelR | last post by:
Hello everbody, In my apps I have list of employees. I want after click on name show new browser window with detail of employee. I know how open info in current window but don't know how open in...
17
by: nicolas.hilaire | last post by:
Hi all, i'm doing a quite long treatment in a function, and i'm showing the progress of the treatment with a progressbar. The code is something like this : for each(entry in entries) // about...
3
by: Mat | last post by:
You can hide objects like labels or text boxes using the visible property but the problem I have is that the space used by the object is used leaving a blank spot. how can u avoid that?
5
by: trint | last post by:
Hi, I have several arrays that look like this: string productsString0 = new string; After they are no longer needed, How can I reset them as though the program were just started? Thanks,...
7
by: nas | last post by:
Consider this example program which i hav taken from some site #include <iostream> using namespace std; class Base1 { public: virtual void f() { } };
12
by: Angus | last post by:
I am writing a class as a wrapper around a std::map. The class is: template<class TKey, class TValue> class CGeneralMap : protected map<TKey, TValue> At the moment I have basic functions like...
17
by: amit.bolakani.technical | last post by:
#include <iostream> using namespace std; class Person{ public: virtual void print () { cout << "In parent" << endl; } void onlyInPerson() { cout << "Only in Person/parent" << endl; }
9
by: weird0 | last post by:
How does C++ and C# solve the Diamond problem? With the help of interfaces that is. Can anyone elaborate ....... Regards
4
by: thomas | last post by:
template <class T> class BufferQueue{ public: int BufferQueue<T>::pushToQueue(T pkt, int timeout); } template<class T> int BufferQueue<T>::pushToQueue(T pkt, ACE_Time_Value *timeout){...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.