473,581 Members | 2,647 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.UserContr ol. 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(Fals e), EditorBrowsable (EditorBrowsabl eState.Never)> Public
Overrides Property ContextMenu() As System.Windows. Forms.ContextMe nu
Get

End Get
Set(ByVal Value As System.Windows. Forms.ContextMe nu)
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 13359
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.

"Crouchie19 98" <cr**********@s pamcop.net> wrote in message
news:uo******** ******@TK2MSFTN GP10.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.c om> wrote in message
news:eV******** ******@TK2MSFTN GP12.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.lg a...
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.c om> wrote in message
news:eV******** ******@TK2MSFTN GP12.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 "Intentiona lly 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.usercontr ol 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 (EditorBrowsabl eState.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.c om> wrote in message
news:%2******** ********@TK2MSF TNGP14.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

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

Similar topics

2
2494
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 escape key on second form, this should be hidded and should show the first form.... Can some one guide me how to achive this... (MUST USE SHOW &...
1
1176
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") {alert("You are retriving prop1"); return this.prop2;}; else {alert("You are setting prop1 to" + input); this.prop2 = input;};
0
1528
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 in the Propertygrid control , but i want only show m custom made properties. How can i easy hide those properties ?
1
1829
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 lot of thing like visible.... I just want to have 1 choice : Beep. What have I to do to hide other properties, fonctions and events ? Thanks
10
2565
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 the base class properties from showing up in the inherited class when people change its properties in the IDE? thanks!
5
1742
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 derive from it to hide the properties however then one always have to inherit from the base object which is not that great in this situation. Is there...
2
1915
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 grid capabilities from scratch. However, it also gives the users of my control all the functionality of the DataGridView as well and that's proving...
3
5117
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 the propertyGrid....removing the "AccessibleName" properties by example? Any example about how to play with the PropertyDescriptorCollection to...
1
1477
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: http://bytes.com/topic/visual-basic-net/answers/349635-binding-collection-datagrid-without-showing-all-columns Briefly, I'm binding the grid to the...
0
8151
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7900
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...
0
8176
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6555
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...
1
5677
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5365
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...
0
3806
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...
1
1404
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1139
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...

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.