1: public class A
2: {
3: public string Name { get; set; }
4:
5: public string Age { get; set; }
6:
7: public bool IsOk { get; set; }
8:
9: [Browsable(false)]
10: public bool Visiable { get; set; }
11: }
12:
13: private void button1_Click(object sender, EventArgs e)
14: {
15: A a = new A();
16: Type type = typeof(BrowsableAttribute);
17:
18: PropertyDescriptorCollection props = TypeDescriptor.GetProperties(a);
19: AttributeCollection attrs = props["Visiable"].Attributes;
20:
21: FieldInfo fld = type.GetField("browsable", BindingFlags.Instance | BindingFlags.NonPublic);
22: fld.SetValue(attrs[type], true);
23:
24: this.propertyGrid1.SelectedObject = a;
25: }