代码:
///动态修改特性 PropertyDescriptorCollection dataAttributes = TypeDescriptor.GetProperties(data);
Type displayType = typeof(BrowsableAttribute);
var fieldInfo = displayType.GetField("browsable", BindingFlags.NonPublic | BindingFlags.Instance);
fieldInfo.SetValue(dataAttributes["Color"].Attributes[displayType], true);
需要注意的是,这里修改的是特性BrowsableAttribute 私有字段browsable,由于自动属性Browsable并没有set方法,只好如此了,如果有更好的方法,希望大神指导!