473,499 Members | 1,909 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

hide existing property

Hi,

I derived a control to create my custom control.
However, some of the control base properties are useless from my point
of view and i would like to avoid control user to change them.

How can i do that ?

I need to hide them from Property window editor but also to make them
not reachable via code line.

thanks a lot,

Al.
Feb 8 '07 #1
6 2306
--== Alain ==-- wrote:
I derived a control to create my custom control.
However, some of the control base properties are useless from my point
of view and i would like to avoid control user to change them.
[...]

The idea of inheritance is to *add* functionality to a class, not take
it away. That said, there really is no way to accomplish your desired goal.

Hope that helps,

--
Sean

website: http://senfo.blogspot.com
Feb 8 '07 #2
Alain,

You can hide them from the proeprty window by applying Browsable(false)
attribute to them. You can also hide them from IntelliSense by applying
EditorBrowsable(EditorBrowsableState.Never) attribute. You cannot remove
them from the class though. This would be against object oriented
principles.

To apply those attributes you need to override or hide the base class
properties. In case of overriding (virtual properties) you can implement
your new version to throw exception if the user tries to set values. With
non-virtual properties there is not complete solution. The new version that
hides the base property can throw exception, but if the user uses reference
to the object that is of type the base class nothing could stop her/him of
setting new values.

--
HTH
Stoitcho Goutsev (100)
"--== Alain ==--" <no****@noemail.comwrote in message
news:%2******************@TK2MSFTNGP05.phx.gbl...
Hi,

I derived a control to create my custom control.
However, some of the control base properties are useless from my point of
view and i would like to avoid control user to change them.

How can i do that ?

I need to hide them from Property window editor but also to make them not
reachable via code line.

thanks a lot,

Al.

Feb 8 '07 #3
I derived a control to create my custom control.
However, some of the control base properties are useless from my point of
view and i would like to avoid control user to change them.

How can i do that ?

I need to hide them from Property window editor but also to make them not
reachable via code line.

thanks a lot,
In addition to what Stoitcho already said, there are other measues you can
take such as changing the property's access specifier in your derived class,
implementing "ICustomTypeDescriptor" (or using its new 2.0 cousin
"TypeDescriptionProviderAttribute)", etc (where you can completely redefine
the properties that will be accessible in a property grid). However, this is
not a panacea and will only complicate your life. My personal opinion is to
simply create a new control that wraps the old one instead of inheriting
from it. You can then delegate to the old control as needed and expose only
those properties you want. Note BTW that you usually don't need to expose
all members of the original control at once. I personally only expose those
methods/properties I actually need and add to it on an as-needed basis.
Feb 8 '07 #4
--== Alain ==-- <no****@noemail.comwrote:
I derived a control to create my custom control.
However, some of the control base properties are useless from my point
of view and i would like to avoid control user to change them.

How can i do that ?

I need to hide them from Property window editor but also to make them
not reachable via code line.
That would break Liskov's Substitutability Principle. If you don't want
to inherit members from a class, don't derive from that class.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Feb 8 '07 #5
Why not create a facade for this class. You can make a private field for the
class you want to derive from. So don't inherit from it but make it private
available in your facade class through compisition.

HTH

Bart

"--== Alain ==--" <no****@noemail.comschreef in bericht
news:%2******************@TK2MSFTNGP05.phx.gbl...
Hi,

I derived a control to create my custom control.
However, some of the control base properties are useless from my point of
view and i would like to avoid control user to change them.

How can i do that ?

I need to hide them from Property window editor but also to make them not
reachable via code line.

thanks a lot,

Al.

Feb 8 '07 #6
available in your facade class through compisition.
>
Sorry typo:

That should be composition of course :)

Bart
Feb 8 '07 #7

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

Similar topics

6
11451
by: adrien | last post by:
Hi, (also posted in netscape.public.mozilla.browser) i use netscape 7 and want to hide the scrollbars of the window when something happens. I tried this: window.scrollbars.visible=false...
5
4472
by: Steve | last post by:
Visual Studio 2003 C# Windows: I have a tree view control as my main menu control down the left side of my application. This has 2 Parent Nodes on it (Jobs and Employees). beneath these 2 main...
1
11889
by: Don Grover | last post by:
I have a table thats wrapped in a div tag, that when user selects 1 of 2 radio buttons it hides or shows table, this works ok. But I want to set the table show hide on what the existing state of...
19
6850
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
3
2928
by: alex | last post by:
I'd like to have a show/hide widget on my web site, kind of like "show details" / "hide details" in Google Groups. Is there a tutorial explaining how to make them? Google's is a bit complex and...
4
1545
by: BrianDH | last post by:
Hi I have an application with 3 windows forms. One of which I load at startup but hide, then show/hide based on users click. How can I test to see if the windows is hidden, or is at the moment...
9
3481
by: Martin Widmer | last post by:
Hello! I would like to hide one property of a base class in a derived class. How could it be done? I tried to override it with a private property, but that doesn't seem to do the hiding. ...
7
29118
by: FP | last post by:
I'm new to Java Script. I'm displaying comments people have made. Below each persons' comment I want to add 2 buttons "Reply" and "Amend". Clicking "Reply" would display an empty text field...
8
5850
by: active | last post by:
If I create a UserControl that inherits from, say, Panel, and I do not want my UserControl to have a property that it inherits from Panel. How can I remove it. For example, I might not want by...
0
7131
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
7174
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,...
1
6894
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
5470
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,...
1
4919
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...
0
4600
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...
0
3099
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...
0
3091
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
297
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...

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.