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;
}
[quoted text, click to view] "AviD" <avi@newsgroup.nospam> wrote in message
news:3C8FE87A-D7AB-430D-8946-FBD0CB61085C@microsoft.com...
> 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.
>
> --
> Avi
> American Society of Composers Authors and Publishers
> New York, NY
>