In C#, when using a PropertyGrid
where an object has a Collection
, what determines if the value next to the DisplayName
shows the value of "(Collection)"
?
Is there a specific attribute for this value?
Thanks
In C#, when using a PropertyGrid
where an object has a Collection
, what determines if the value next to the DisplayName
shows the value of "(Collection)"
?
Is there a specific attribute for this value?
Thanks
You can use TypeConverters.
public class MyCollectionTypeConverter : TypeConverter
{
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (value is List<string>)
{
return string.Join(",", ((List<string>) value).Select(x => x));
}
return base.ConvertTo(context, culture, value, destinationType);
}
}
and add as attribute;
[TypeConverter(typeof(MyCollectionTypeConverter))]
public List<string> Prop1 { get; set; }