- I use a PropertyGrid to allow the enduser to edit properties from a class
ClassA
- This class has a
List<ClassB>
property. - For the
List<ClassB>
property, the PropertyGrid shows(Collection)
and a button with 3 dots which opens a new windows which looks like this (taken from another SO post).
I want to customize the
Members:
DisplayName on the left, so forClassB
I have overridden theToString()
methodpublic class ClassB { public string Name { get; set; } public TimeSpan Value { get; set; } public override ToString() { return String.Format("{0} ({1})", this.Name, this.Value); } }
Now here comes the problem:
- If Name is empty, it shows
(00:00:00)
as expected. - If I change the name to Test I expect it to show
Test (00:00:00)
, but it just showsTest
- If I rename the property Name to something else, it works as expected.
I suppose this is a special conventions that, if a class has a property Name
and the value is not null or empty, the control shows this property rather than the name.
However, I have not found a doc that verifies that and I don't know how to change this behaviour. How do I achive this?
Note: Changing the property name is not an option.