473,756 Members | 8,174 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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)i nova.ch
Nov 15 '05 #1
1 4238
Marc Scheuner [MVP ADSI] <m.********@ino va.SPAMBEGONE.c h> 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
Substitutabilit y 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.co m>
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
967
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
1244
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 other (new) browser window. And second problem how hide toolbar in new window and how set property for new window. Thanks, PawelR
17
23712
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 100 entries { TreatmentForOneOr2Secs(); this->progressBar1->PerformStep();
3
1048
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
16700
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, Trint
7
1377
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
3578
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 Add, Remove etc but I am really struggling with GetValue, which will be like the value obtained from
17
1484
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
10976
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
1410
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){ cout<<"in pushToQueue"<<endl; --------Line p return 0;
0
9384
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9212
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9790
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9779
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8645
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6473
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5069
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3276
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2612
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.