Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 29th, 2008, 05:44 AM
Friend of Wrox
 
Join Date: Dec 2006
Posts: 176
Thanks: 0
Thanked 0 Times in 0 Posts
Default Remove Properties

Hi,
I use the flowing code in my usercontrolDesignerClass to remove some properties:
Code:
 protected override void PreFilterProperties(System.Collections.IDictionary properties)
        {
           properties.Remove("BackColor");

        }
it works fun and user cann't access the "BackColor" property in desgin view at property grid. but also user can access it bye coding such as :
myUserControl.BackColor =// A color

how can i remove the properties in both design view and code view
thanks
 
Old March 29th, 2008, 05:45 PM
Authorized User
 
Join Date: Sep 2007
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default

To put it simply, you can't.
 
Old March 29th, 2008, 06:24 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Hmm. Why would you want to do this??? If you are devloping controls that you are intending to sell (or give away for that matter) you should NOT restrict a potential client or developer from changing how the control looks. For example, if your control is bright neon pink and yellow and I have a more contemporary website or application that I want to plug your control into but you restrict me from altering its appearance, why am I going to buy it?

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
 
Old March 30th, 2008, 03:46 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

I agree with dparsons, the whole reason the BackColor property is part of the base control class is because EVERY control should have complete flexibility over how it looks by its client code. This is not just because people may like to change it (and they should be able to if they want to), but also an Accessibility issue, some people may be color blind, need high contrast to read clearly etc.

However, you could override it and mark it as obsolete, I think that would throw compiler warnings at you though, since the base BackColor is not obsolete, but would enable you to now allow client code to call it. Not sure, never tried it!


Rob
The Developing Developer
Currently Working Towards: MCAD C#
My Blog: http://www.robzyc.spaces.live.com
<center>"Nothing can stop the man with the right mental attitude from achieving his goal;
nothing on earth can help the man with the wrong mental attitude".

Thomas Jefferson</center>
 
Old March 30th, 2008, 09:38 AM
Friend of Wrox
 
Join Date: Dec 2006
Posts: 176
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by dparsons
 Hmm. Why would you want to do this??? If you are devloping controls that you are intending to sell (or give away for that matter) you should NOT restrict a potential client or developer from changing how the control looks. For example, if your control is bright neon pink and yellow and I have a more contemporary website or application that I want to plug your control into but you restrict me from altering its appearance, why am I going to buy it?

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
ooohh
the property "BackColor" is just a sample. my question is about all properties. and be sure if i remove the backColor property(that i do this action never), i will add the new property with feature greater than the BackColor..
but my question is abou any property.. i don't want realy remove the BackColor property..
i just want to now how can i remove some property of control from code view and design view...
regards
 
Old March 30th, 2008, 09:44 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
quote:To put it simply, you can't.
Of course you can...

Simply decorate your properties with attributes like EditorBrowsableAttribute and BrowsableAttribute to hide them from the Grid and IntelliSense:

http://msdn2.microsoft.com/en-us/lib...attribute.aspx
http://msdn2.microsoft.com/en-us/lib...attribute.aspx

Combine that with an ObsoleteAttribute to discourage the use of the property, and it's unlikely people will find / use it. Additionally, you can override the property and have it throw a NotImplementedException.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.





Similar Threads
Thread Thread Starter Forum Replies Last Post
remove form properties angelboy C# 2005 4 June 30th, 2007 01:23 PM
remove returns redruff Classic ASP Basics 13 January 9th, 2007 11:56 PM
How to remove ? abdusalam Javascript How-To 1 July 27th, 2004 01:24 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.