Hi Lance,
I think you may also try to inherits the GetProperties and
GetPropertiesSu pported method.
Here is some code for your reference.
NOTE: the code has not been detailed tested, you may need to change
according to your scenario.
Thanks!
BTW:
For designtime issue, we have a specified newsgroup as below.
microsoft.publi c.dotnet.framew ork.windowsform s.designtime
Dim pt As New PointF(1.1F, 2.2F)
<TypeConverter( GetType(PointFC onverter))> _
Public ReadOnly Property TestPt() As PointF
Get
Return pt
End Get
End Property
End Class
Public Class PointFConverter
Inherits ExpandableObjec tConverter
' Methods
Public Sub New()
End Sub
Public Overloads Function CanConvertFrom( ByVal context As
ITypeDescriptor Context, ByVal sourceType As Type) As Boolean
If (sourceType Is GetType(String) ) Then
Return True
End If
Return MyBase.CanConve rtFrom(context, sourceType)
End Function
Public Overloads Function CanConvertTo(By Val context As
ITypeDescriptor Context, ByVal destinationType As Type) As Boolean
If (destinationTyp e Is GetType(Instanc eDescriptor)) Then
Return True
End If
Return MyBase.CanConve rtTo(context, destinationType )
End Function
Public Overloads Function ConvertFrom(ByV al context As
ITypeDescriptor Context, ByVal culture As CultureInfo, ByVal value As
Object) As Object
If Not TypeOf value Is String Then
Return MyBase.ConvertF rom(context, culture, value)
End If
Dim text1 As String = CType(value, String).Trim
If (text1.Length = 0) Then
Return Nothing
End If
If (culture Is Nothing) Then
culture = CultureInfo.Cur rentCulture
End If
Dim ch1 As Char = culture.TextInf o.ListSeparator .Chars(0)
Dim chArray1 As Char() = New Char() {ch1}
Dim textArray1 As String() = text1.Split(chA rray1)
Dim numArray1 As Single() = New Single(textArra y1.Length - 1) {}
Dim converter1 As TypeConverter =
TypeDescriptor. GetConverter(Ge tType(Integer))
Dim num1 As Single
For num1 = 0 To numArray1.Lengt h - 1
numArray1(num1) = CType(converter 1.ConvertFromSt ring(context,
culture, textArray1(num1 )), Integer)
Next num1
If (numArray1.Leng th = 2) Then
Return New PointF(numArray 1(0), numArray1(1))
End If
Dim objArray1 As Object() = New Object() {text1, "x, y"}
End Function
Public Overloads Function ConvertTo(ByVal context As
ITypeDescriptor Context, ByVal culture As CultureInfo, ByVal value As
Object, ByVal destinationType As Type) As Object
If (destinationTyp e Is Nothing) Then
Throw New ArgumentNullExc eption("destina tionType")
End If
If ((destinationTy pe Is GetType(String) ) AndAlso TypeOf value Is
PointF) Then
Dim point1 As PointF = CType(value, PointF)
If (culture Is Nothing) Then
culture = CultureInfo.Cur rentCulture
End If
Dim text1 As String = (culture.TextIn fo.ListSeparato r & " ")
Dim converter1 As TypeConverter =
TypeDescriptor. GetConverter(Ge tType(Single))
Dim textArray1 As String() = New String(2 - 1) {}
Dim num1 As Single = 0
textArray1(num1 ) = converter1.Conv ertToString(con text, culture,
point1.X)
num1 += 1
textArray1(num1 ) = converter1.Conv ertToString(con text, culture,
point1.Y)
Return String.Join(tex t1, textArray1)
End If
If ((destinationTy pe Is GetType(Instanc eDescriptor)) AndAlso TypeOf
value Is Point) Then
Dim point2 As Point = CType(value, Point)
Dim typeArray1 As Type() = New Type() {GetType(Intege r),
GetType(Integer )}
Dim info1 As ConstructorInfo =
GetType(Point). GetConstructor( typeArray1)
If (Not info1 Is Nothing) Then
Dim objArray1 As Object() = New Object() {point2.X,
point2.Y}
Return New InstanceDescrip tor(info1, objArray1)
End If
End If
Return MyBase.ConvertT o(context, culture, value, destinationType )
End Function
Public Overloads Function GetProperties(B yVal context As
ITypeDescriptor Context, ByVal value As Object, ByVal attributes As
Attribute()) As PropertyDescrip torCollection
Dim collection1 As PropertyDescrip torCollection =
TypeDescriptor. GetProperties(G etType(PointF), attributes)
Dim textArray1 As String() = New String() {"X", "Y"}
Return collection1.Sor t(textArray1)
End Function
Public Overloads Function GetPropertiesSu pported(ByVal context As
ITypeDescriptor Context) As Boolean
Return True
End Function
End Class
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.