private void Custom_AutoGeneratingPropertyGridItem(object sender, AutoGeneratingPropertyGridItemEventArgs e)
{
if (e.DisplayName == "SpouseName")
{
PropertyDescriptor descriptor = TypeDescriptor.GetProperties(Custom.SelectedObject.GetType())["IsMarried"];
object value = descriptor.GetValue(Custom.SelectedObject);
e.ReadOnly = !((bool)value);
}
}
public bool IsMarried
{
get { return isMarried; }
set
{
isMarried = value;
PropertyGrid.RefreshPropertygrid();
}
} |