Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / January 2005

Tip: Looking for answers? Try searching our database.

Controlling properties at design time

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AviD - 04 Jan 2005 13:07 GMT
Hi,
What will be the best way to manage, dynamically, during design time
properties of a control. For example, I would like to hide a certain property
description, when other property is assigned a certain value. I've tried
something like
Dim properties As PropertyDescriptorCollection =
TypeDescriptor.GetProperties(Controll) and going through the collection with
Dim mP As PropertyDescriptor, but it seems to me that not all the properties
are found in the collection, also, I can't  get properties that reside under
a ExpandableObjectConverter. I need to find a method that will hide and
unhide a property descriptor.

Signature

Avi
American Society of Composers Authors and Publishers
New York, NY

"Jeffrey Tan[MSFT]" - 05 Jan 2005 07:24 GMT
Hi Avi,

Thanks for your posting!

Based on my understanding, you want to dynamically filtrate/add some
properties for certain control at design-time.

Actually, the standard way of manipulating the properties collection of
certain control is adding ControlDesigner/ComponentDesigner to the control,
then the control's design-time behavior will be controlled by this
ControlDesigner/ComponentDesigner.

We should override ControlDesigner/ComponentDesigner's several methods:
PreFilterProperties
PostFilterProperties
PreFilterAttributes
PostFilterAttributes
PreFilterEvents
PostFilterEvents

Rules:
The general rule to follow is to add or remove items(properties or events)
in the "PreFilter..." methods, and modify existing items(properties or
events) in the "PostFilter..." methods. Always call the base method first
in the PreFilter methods and call the base method last in the PostFilter
methods.

For a details explaination and samples, please refer to the good article
below:
"Writing Custom Designers for .NET Components"
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/ht
ml/custdsgnrdotnet.asp
============================================================================
=====
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

joeycalisay - 06 Jan 2005 05:08 GMT
Although they say that it's a bad design to have dependent properties, here
is how i got it worked before:

Implement ICustomTypeDescriptor on your component then override the
BrowsableAttribute of the affected properties returned from both
GetProperties method based on your test (dependence on other properties).

                       PropertyDescriptorCollection
System.ComponentModel.ICustomTypeDescriptor.GetProperties()

                       {

                                   PropertyDescriptorCollection baseProps =

TypeDescriptor.GetProperties(this, attributes, true);

                                   PropertyDescriptor[] props = null;

                                   for (int i = 0; i < baseProps.Count;
i++)

                                   {

                                               if
(ShouldHideProperty(baseProps[i]))

                                               {

                                                           if (props ==
null)

                                                           {

props = new PropertyDescriptor[baseProps.Count];

baseProps.CopyTo(props, 0);

                                                           }

                                                           props[i] =
TypeDescriptor.CreateProperty(

this.GetType(),

baseProps[i],

BrowsableAttribute.No);

                                               }

                                   }

                                   if (props == null)

                                   {

                                               return baseProps;

                                   }

                                   return new
PropertyDescriptorCollection(props);

                       }

                       private bool ShouldHideProperty(PropertyDescriptor
pd)

                       {

                                   if(this.independentProperty == somevalue
&& pd.Name == "DependentProperty") return true;

                                   return false;

                       }

> Hi,
> What will be the best way to manage, dynamically, during design time
[quoted text clipped - 7 lines]
> a ExpandableObjectConverter. I need to find a method that will hide and
> unhide a property descriptor.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.