The last property is an array of structures. I achieve correct representation by overriding the ToString
of structures, but it is impossible to override the ToString
of an array. I try to use TypeConverter
it works but the property becomes non-expandable.
This is TypeConverter
:
Public Class StringViewArrayViewConverter
Inherits CollectionConverter
#Region "Public Methods"
Public Overrides Function ConvertTo(context As ITypeDescriptorContext,
culture As CultureInfo,
value As Object,
destinationType As Type) As Object
If TypeOf value Is dpStringView() AndAlso destinationType.Equals(GetType(String)) Then
Return FormatNumber(CType(value, dpStringView()).Length, 0)
Else
Return String.Empty
End If
End Function
#End Region
End Class
That used in a next way:
<Category(CategoryInfo)>
<DisplayName("Придатний")>
<TypeConverter(GetType(StringViewArrayViewConverter))>
Public ReadOnly Property SuitabilityDescription As dpStringView()
Get
Return Array.ConvertAll(Suitability, Function(i) New dpStringView(GetEnumDescription(i)))
End Get
End Property
The next picture illustrates PropertyGrid
without TypeConverter
.
Is it possible to replace dpStrinViev[] Array
with some short conclusion from its contents (like "1 message, expand to see details") and leave the property expandable?
Thanks for any advice or examples in VB.NET or C#
I find my mistake: my TypeConverter
inherits CollectionConverter
instead ArrayConverter
.