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

Hide unwanted properties.

Ok, I have finally decided that there is ONE big thing about VB.NET (not
sure if this same thing exists in C# yet) that really ticks me off. Either I
am missing the point here or I have not found what I need to accomplish my
need.

I am creating a Windows forms user control and am inheriting from
System.Windows.Forms.UserControl. There are several properties that are part
of the Usercontrol class that I do not want to expose so I am trying to hide
them as shown below:

<Browsable(False), EditorBrowsable(EditorBrowsableState.Never)> Public
Overrides Property ContextMenu() As System.Windows.Forms.ContextMenu
Get

End Get
Set(ByVal Value As System.Windows.Forms.ContextMenu)
End Set

End Property

But when I place the control on a form and look the properties I have tried
to hide are still present through IntelliSense. Is this not what the
EditorBrowsable attribute is supposed to stop?

--
Raymond R Cassick
CEO / CSA
Enterprocity Inc.
www.enterprocity.com
3380 Sheridan Drive, #143
Amherst, NY 14227
V: 716-316-7537
Blog: http://spaces.msn.com/members/rcassick/
Nov 21 '05 #1
12 13334
Browsable(False) _
Public Property Bla Bla Bla() As Bla
....
End Property

This will only remove the property from the properties dialog, but not if
you try to accress them in code

Crouchie1998
BA (HONS) MCP MCSE
Nov 21 '05 #2
Yeah, I know that... I can't believe that there is no way to hide this from
code though. It looks like the only thing I can do it thrown an exception if
one of my users tries to use a property that I have not implemented.

Seems mighty messy to me.

I have read a few theories that say hiding inherited properties made
available form a base class is 'bad OO' but I don't think it is. What about
polymorphisam? There are some things I want my control to do differently.
I want to have full control over what MY usercontrol exposes to MY user. I
don't want to have to implement a bunch of properties I don't care about
just because of the base class I chose to use.

UGH!

I don't want users to be bale to change my background picture so why should
I have that available on my list of properties? More so, if it is available
why would it throw an exception when someone tries to use it?

Just seems VERY messy tome.

"Crouchie1998" <cr**********@spamcop.net> wrote in message
news:uo**************@TK2MSFTNGP10.phx.gbl...
Browsable(False) _
Public Property Bla Bla Bla() As Bla
...
End Property

This will only remove the property from the properties dialog, but not if
you try to accress them in code

Crouchie1998
BA (HONS) MCP MCSE

Nov 21 '05 #3
Just a thought, but what if you override the property but make it's scope
Private? Not even sure if this is possible, but it might be worth
checking... Alternatively, instead of throwing an exception, you could make
the property do nothing at all if a user tries to assign a value to it -
just make sure you document that the property has no effect...

Just a couple things to try. Good luck.

"Ray Cassick (Home)" <rc************@enterprocity.com> wrote in message
news:eV**************@TK2MSFTNGP12.phx.gbl...
Yeah, I know that... I can't believe that there is no way to hide this
from code though. It looks like the only thing I can do it thrown an
exception if one of my users tries to use a property that I have not
implemented.

Seems mighty messy to me.

I have read a few theories that say hiding inherited properties made
available form a base class is 'bad OO' but I don't think it is. What
about polymorphisam? There are some things I want my control to do
differently.
I want to have full control over what MY usercontrol exposes to MY user. I
don't want to have to implement a bunch of properties I don't care about
just because of the base class I chose to use.

UGH!

I don't want users to be bale to change my background picture so why
should I have that available on my list of properties? More so, if it is
available why would it throw an exception when someone tries to use it?

Just seems VERY messy tome.

Nov 21 '05 #4
Unfortunately, as handy as that would be sometimes, you can't do it. If
you override a member it must have the same scope as it's base -
otherwise you would totally break polymorphism.

I agree with your second point though: I think the best idea would be
the override the property to ensure it has no effect when called by the
user. Don't worry about throwing exceptions, it's probably not worth the
effort (although you can if you really want to). Your users will quickly
find out the property is useless when it doesn't do anything ;)

Also as Michael mentioned: make sure you document it.

Regards,
-Adam.

Michael C# wrote:
Just a thought, but what if you override the property but make it's scope
Private? Not even sure if this is possible, but it might be worth
checking... Alternatively, instead of throwing an exception, you could make
the property do nothing at all if a user tries to assign a value to it -
just make sure you document that the property has no effect...

Just a couple things to try. Good luck.

Nov 21 '05 #5
If you make them Private Shadows they still seem to show up in the IDE.

If you make them Private Overrides you get an error saying that you can't do
that because the base class has a different access level (public).

Nice try though :) I have been at it all night trying to come up with a way
and I have come to the conclusion that there is no way right now.

I weighed the cost (user experience) regarding throwing an exception vs.
just not dealing with them and I think the latter is way more confusing. To
be bale to assign data through a property and simply have nothing happen
looks to the user more like a bug, even if it is documented that the
property is not implemented. Do users ever read the docs? :)

Perhaps if I created a category of 'Not Implemented and put them all under
there....

Isn't there some attribute that allows you to mark things as deprecated?
Hmmm Maybe I could just mark them all with the Obsolete attribute...
"Michael C#" <xy*@abcdef.com> wrote in message
news:W8***************@fe11.lga...
Just a thought, but what if you override the property but make it's scope
Private? Not even sure if this is possible, but it might be worth
checking... Alternatively, instead of throwing an exception, you could
make the property do nothing at all if a user tries to assign a value to
it - just make sure you document that the property has no effect...

Just a couple things to try. Good luck.

"Ray Cassick (Home)" <rc************@enterprocity.com> wrote in message
news:eV**************@TK2MSFTNGP12.phx.gbl...
Yeah, I know that... I can't believe that there is no way to hide this
from code though. It looks like the only thing I can do it thrown an
exception if one of my users tries to use a property that I have not
implemented.

Seems mighty messy to me.

I have read a few theories that say hiding inherited properties made
available form a base class is 'bad OO' but I don't think it is. What
about polymorphisam? There are some things I want my control to do
differently.
I want to have full control over what MY usercontrol exposes to MY user.
I don't want to have to implement a bunch of properties I don't care
about just because of the base class I chose to use.

UGH!

I don't want users to be bale to change my background picture so why
should I have that available on my list of properties? More so, if it is
available why would it throw an exception when someone tries to use it?

Just seems VERY messy tome.


Nov 21 '05 #6
Ray,

When you look in the controls, you can see as well some properties which are
in my opinion shadowed. They are there however do nothing.

Just my thought,

Cor
Nov 21 '05 #7
> Isn't there some attribute that allows you to mark things as deprecated?
Hmmm Maybe I could just mark them all with the Obsolete attribute...

and a description attribute saying "Intentionally not implemented"
Nov 21 '05 #8
Either I am missing the point here or I have not found what I need to

accomplish my need.

I think you are. If you dont want to expose all of the functionality of a
base class then dont inherit from it. Whatever you do your user will still
be able to cast down and access baseclass properties anyway. Look into the
inheritence tree where maybe something deeper down will better suit your
needs.

Richard
Nov 21 '05 #9
But then that means that I loose all the implementation that I DO want from
the base :)

I suppose that I could look into using Panel as a base class and inherit
from there, but really, if any of the controls inherit from
System.Windows.Forms.usercontrol then I end up getting all that baggage.

Sounds like I need to inherit from object and just build my own completely
ownerdrawn control. :(

Really though, my big beef here is that MS gives us the
EditorBrowsable(EditorBrowsableState.Never) but it apparently does not do
anything. If it does nothing then why have it. It seems like this was the
exact scenario this attribute was designed for.

"Richard Myers" <fa**@address.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Either I am missing the point here or I have not found what I need to

accomplish my need.

I think you are. If you dont want to expose all of the functionality of a
base class then dont inherit from it. Whatever you do your user will still
be able to cast down and access baseclass properties anyway. Look into the
inheritence tree where maybe something deeper down will better suit your
needs.

Richard

Nov 21 '05 #10
Yes, I can get it removed form the property box... I want it removed from
the code window as well. I don't want it to show up in IntelleSense.

When someone types:

ControlName.

I don't want it to show up there either. As far as I have been told you
can't block that...
"Richard Myers" <fa**@address.com> wrote in message
news:uz**************@tk2msftngp13.phx.gbl...
O.k well ive tried to replicate your query and context menu example you
described and for me it works.
Context Menu is NOT available via the forms property box.

Richard

"Ray Cassick" <rc******@nospam.enterprocity.com> wrote in message
news:ex**************@TK2MSFTNGP09.phx.gbl...
But then that means that I loose all the implementation that I DO want from
the base :)

I suppose that I could look into using Panel as a base class and inherit
from there, but really, if any of the controls inherit from
System.Windows.Forms.usercontrol then I end up getting all that baggage.

Sounds like I need to inherit from object and just build my own

completely
ownerdrawn control. :(

Really though, my big beef here is that MS gives us the
EditorBrowsable(EditorBrowsableState.Never) but it apparently does not do
anything. If it does nothing then why have it. It seems like this was the exact scenario this attribute was designed for.

"Richard Myers" <fa**@address.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...

> Either I am missing the point here or I have not found what I need to accomplish my need.

I think you are. If you dont want to expose all of the functionality

of a base class then dont inherit from it. Whatever you do your user will still be able to cast down and access baseclass properties anyway. Look into the inheritence tree where maybe something deeper down will better suit your needs.

Richard



Nov 21 '05 #11
Hmm I think Microsoft need to define what they mean by "Editor". I was
thinking it just meant the editors in design view in this sense given the
Intellisense it really just a cut down object inspector, but i can see how
you could interpret as CodeWindow Editor.

Perhaps its just a very poorly named Attribute or maybe you have to apply
the attribute at the inheritence hierarchy level where the property/method
is *first* defined. I.e because you're overridding you wont be able to hide
it through the use of this attribute but if it were a property you defined
that was going to be subclassed then applying this attirbute would hide it
from *future generations*.

Richard

"Ray Cassick" <rc******@nospam.enterprocity.com> wrote in message
news:eP**************@TK2MSFTNGP12.phx.gbl...
Yes, I can get it removed form the property box... I want it removed from
the code window as well. I don't want it to show up in IntelleSense.

When someone types:

ControlName.

I don't want it to show up there either. As far as I have been told you
can't block that...
"Richard Myers" <fa**@address.com> wrote in message
news:uz**************@tk2msftngp13.phx.gbl...
O.k well ive tried to replicate your query and context menu example you
described and for me it works.
Context Menu is NOT available via the forms property box.

Richard

"Ray Cassick" <rc******@nospam.enterprocity.com> wrote in message
news:ex**************@TK2MSFTNGP09.phx.gbl...
But then that means that I loose all the implementation that I DO want
from
the base :)

I suppose that I could look into using Panel as a base class and
inherit from there, but really, if any of the controls inherit from
System.Windows.Forms.usercontrol then I end up getting all that baggage.
Sounds like I need to inherit from object and just build my own completely
ownerdrawn control. :(

Really though, my big beef here is that MS gives us the
EditorBrowsable(EditorBrowsableState.Never) but it apparently does
not do anything. If it does nothing then why have it. It seems like this was the exact scenario this attribute was designed for.

"Richard Myers" <fa**@address.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
>
> > Either I am missing the point here or I have not found what I
need
to > accomplish my need.
>
> I think you are. If you dont want to expose all of the
functionality of
a
> base class then dont inherit from it. Whatever you do your user

will still
> be able to cast down and access baseclass properties anyway. Look
into the
> inheritence tree where maybe something deeper down will better suit

your
> needs.
>
> Richard
>
>



Nov 21 '05 #12
Yeah, the Browseable attribute I get. It hides the property from the
property browser. But that EditorBrowsable just makes no sense to me.
"Richard Myers" <fa**@address.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hmm I think Microsoft need to define what they mean by "Editor". I was
thinking it just meant the editors in design view in this sense given the
Intellisense it really just a cut down object inspector, but i can see how
you could interpret as CodeWindow Editor.

Perhaps its just a very poorly named Attribute or maybe you have to apply
the attribute at the inheritence hierarchy level where the property/method
is *first* defined. I.e because you're overridding you wont be able to
hide
it through the use of this attribute but if it were a property you defined
that was going to be subclassed then applying this attirbute would hide it
from *future generations*.

Richard

"Ray Cassick" <rc******@nospam.enterprocity.com> wrote in message
news:eP**************@TK2MSFTNGP12.phx.gbl...
Yes, I can get it removed form the property box... I want it removed from
the code window as well. I don't want it to show up in IntelleSense.

When someone types:

ControlName.

I don't want it to show up there either. As far as I have been told you
can't block that...
"Richard Myers" <fa**@address.com> wrote in message
news:uz**************@tk2msftngp13.phx.gbl...
> O.k well ive tried to replicate your query and context menu example you
> described and for me it works.
> Context Menu is NOT available via the forms property box.
>
> Richard
>
> "Ray Cassick" <rc******@nospam.enterprocity.com> wrote in message
> news:ex**************@TK2MSFTNGP09.phx.gbl...
> > But then that means that I loose all the implementation that I DO want > from
> > the base :)
> >
> > I suppose that I could look into using Panel as a base class and inherit > > from there, but really, if any of the controls inherit from
> > System.Windows.Forms.usercontrol then I end up getting all that baggage. > >
> > Sounds like I need to inherit from object and just build my own
> completely
> > ownerdrawn control. :(
> >
> > Really though, my big beef here is that MS gives us the
> > EditorBrowsable(EditorBrowsableState.Never) but it apparently does not
do
> > anything. If it does nothing then why have it. It seems like this was

the
> > exact scenario this attribute was designed for.
> >
> >
> >
> > "Richard Myers" <fa**@address.com> wrote in message
> > news:%2****************@TK2MSFTNGP14.phx.gbl...
> > >
> > > > Either I am missing the point here or I have not found what I

need
to
> > > accomplish my need.
> > >
> > > I think you are. If you dont want to expose all of the

functionality
of
> a
> > > base class then dont inherit from it. Whatever you do your user

will > still
> > > be able to cast down and access baseclass properties anyway. Look into > the
> > > inheritence tree where maybe something deeper down will better suit
> your
> > > needs.
> > >
> > > Richard
> > >
> > >
> >
> >
>
>



Nov 21 '05 #13

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

Similar topics

2
by: Ajai Kumar .R | last post by:
Hai all, I've two or more forms on my app. My requirement is, Have to show the first form asa the user press a button have to hide the first form and show the second form. If the user press the...
1
by: bulk88 | last post by:
I want a property. But I dont want it to be a static string. Below is make belive javascript code of what I want. this.prop1 = function (input) {if (input == "none because we are doing output")...
0
by: Peter Verburgh | last post by:
Hello, I'm using PropertyGrid control to show the properties of an control. There are standard properties for each usercontrol like "Cursor, Dock ,...ect" I don't want to show this properties...
1
by: Benoist LUGNIER | last post by:
Hello, I've done a user control named for example myUC with 1 fonction "Beep". When I use it on a project, I put myUC on a form (it is called myUC1). When I type "myUC1.", intellisense give me...
10
by: Smokey Grindle | last post by:
i want to inherit the list view class, but in the inherited class, hide the Header style property and the view property (basically its a detailed list with always clickable headers) how do I keep...
5
by: ajk | last post by:
Hi I was wondering how one normally does to hide standard properties in a user control e.g. X,Y or Width. I have one approach where I have a base object which hides some of the properties and...
2
by: Steve Barnett | last post by:
I've got a calendar control that extends the DataGrid View: public class Calendar : DataGridView This gives me all the functionality I need for my calendar without the hassles of writing the...
3
by: michelqa | last post by:
Hi, I have a form with a control..(a button for example). Then the control properties are displayed in a propertyGrid control. Is there any simple way to remove some unwanted properties from...
1
by: hex74 | last post by:
Hello My problem is similar to the one described in this article, but I'm trying to use a different grid (DevExpress.xtraGrid) and therefore the answer (if it even works) does not apply for me:...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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,...

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.