c# PropertyGrid and Interface property
Problem: when object is having:
class A
{
public ISomeinterface PropertyName { get; set; }
}
and then an instance of that class is assigned to propertyGrid.SelectedObject = new A(); then when trying to edit the value of PropertyName, an exception about fail to make instance of ISomeinterface is shown (make sense of course) the question is how to wo开发者_C百科rkaround this without break my class's and interfaces.?
Right, PropertyGrid has no hope of guessing how to assign the value. So, hide it:
class A
{
[Browsable(false)]
public ISomeinterface PropertyName { get; set; }
}
If property assignment is a requirement then you'll need to implement a UITypeEditor for the property.
精彩评论