Solved

Hiding a property

Posted on 2004-09-01
3
266 Views
Last Modified: 2010-04-15
Hi everyone ..

I have a control NumericTextBox which is inherited from TextBox. Now, TextBox has a property named .Text which I would like to hide from the programmer.

So if the user adds a NumerictextBox to his form, there should be no option .Text

NumericTextBox myNtb = new NumericTextBox();
myNtb.Font ... works
myNtb.Size ... works
myNtb.Text ... doesn't exist


Is there any way how I can do that ?
0
Comment
Question by:somnatic
  • 2
3 Comments
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 500 total points
ID: 11951711
You can't ... the only thing you could do is override the .Text method ...

There is reason for this though. If you could inherit from a class to remove functionality (i.e. externally visible items) you would break polymorphism.
0
 
LVL 4

Author Comment

by:somnatic
ID: 11951769
ok, already thought so .. only couldn't think of a reason ..

but now that's clear .. makes sense as well :)
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11951805
glad to help.

Cheers,

Greg
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question