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.