I have question regarding c# property grid.
public enum xxx
{
[Browsable(true)]
aaa,
[Browsable(false)]
bbb,
[Browsable(true)]
ccc,
}
public class testObject {
public xxx temp;
public xxx test {
get { return temp; }
set { temp = value; }
}
How can I change the browsable attribute at run time?
For example, when btn1 is pressed, I want to set the browsable attribute to false for all, like this:
private void button1_Click(object sender, RoutedEventArgs e)
{
object[] browsable;
Type type = typeof(xxx);
FieldInfo[] fieldInfos = type.GetFields();
foreach (FieldInfo fieldInfo in fieldInfos)
{
browsable = fieldInfo.GetCustomAttributes(typeof(BrowsableAttribute), false);
if (browsable.Length == 1)
{
BrowsableAttribute brAttr = (BrowsableAttribute)browsable[0];
fieldInfo.SetValue(brAttr, false);
}
}
}
but it causes an error.
you can change browsable property in this way...
try this one this may helps you....