Got it working.
The trick was to set the Browsable Attribute to true on all properties, then call the SetBrowsableProperty in the setter of the property.
The trick was to set the Browsable Attribute to true on all properties, then call the SetBrowsableProperty in the setter of the property.
[Category("Projekt")]
[PropertyOrder(1)]
[DisplayName("Projectnumber")]
[Browsable(true)]
public string ProjectNumber
{
get
{
return _projectNumber;
}
set
{
_projectNumber = value;
SetBrowsableProperty("ProjectNumber", !String.IsNullOrEmpty(_projectNumber));
}
}
private void SetBrowsableProperty(string strPropertyName, bool bIsBrowsable)
{
PropertyDescriptor propertyDesc = TypeDescriptor.GetProperties(GetType())[strPropertyName];
BrowsableAttribute attribute = (BrowsableAttribute)propertyDesc.Attributes[typeof(BrowsableAttribute)];
FieldInfo fiedInfo = attribute.GetType().GetField("Browsable", BindingFlags.IgnoreCase | BindingFlags.NonPublic | BindingFlags.Instance);
fiedInfo.SetValue(attribute, bIsBrowsable);
}