Reputation: 12613
Given a class like this:
public class SomeClass
{
public SomeClass()
{
Name = "Default";
Values = Enumerable.Range(1,3).ToArray();
}
public string Name { get; set; }
public int[] Values { get; set; }
}
A default instance of the class appears like this on a PropertyGrid
control:
Is it possible to override the text displayed for the Values
property so it to displays something like 1, 2, 3
instead of Int32[] Array
.
Solutions involving reflection and inheriting from the PropertyGrid
control are welcome.
Upvotes: 2
Views: 786
Reputation: 7737
I think you can add a TypeConverter
attribute to Values
:
[TypeConverter(typeof(IntArrayToStringTypeConverter))]
public int[] Values { get; set; }
Then create a IntArrayToStringTypeConverter
based on the documentation. Not sure if there is already a type converter around that will do what you want.
Upvotes: 2