Good morning,
I'm searching for a way to dynamically hide properties that are 'String.IsNullOrEmpty'.
I tried using reflection:
Any help is highly appreciated.
I'm searching for a way to dynamically hide properties that are 'String.IsNullOrEmpty'.
I tried using reflection:
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);
}
..to set the Browsable Attribute, but that causes the Properties in the PropertyGrid to dissapear completely, independent if they have a value or not.Any help is highly appreciated.