Hi,
I have a class which I am feeding to the propertygrid, and I am
exposing a Mesh object from my class for the propertygrid to display. I
want the propertygrid to show the values (when you expand the property)
and allow those values to be edited. My code is below. The grid is
showing the values but they are read-only, although the other
properties for the rest of my class are editable.
Public Class MeshConverter
Inherits TypeConverter
Public Overrides Function CanConvertFrom( ByVal context As
System.Componen tModel.ITypeDes criptorContext, ByVal sourceType As
System.Type) As Boolean
If sourceType.ToSt ring = "System.Str ing" Then
Return True
Else
Return MyBase.CanConve rtFrom(context, sourceType)
End If
End Function
Public Overrides Function CanConvertTo(By Val context As
System.Componen tModel.ITypeDes criptorContext, ByVal destinationType As
System.Type) As Boolean
Return False
End Function
Public Overrides Function ConvertTo(ByVal context As
System.Componen tModel.ITypeDes criptorContext, ByVal culture As
System.Globaliz ation.CultureIn fo, ByVal value As Object, ByVal
destinationType As System.Type) As Object
If destinationType Is Nothing Then
Throw New ArgumentNullExc eption("destina tionType")
ElseIf value.ToString = "Microsoft.Dire ctX.Direct3D.Me sh" Then
Return "Mesh Object"
Else
Return MyBase.ConvertT o(context, culture, value,
destinationType )
End If
End Function
Public Overrides Function GetProperties(B yVal context As
System.Componen tModel.ITypeDes criptorContext, ByVal value As Object,
ByVal attributes() As System.Attribut e) As
System.Componen tModel.Property DescriptorColle ction
Return TypeDescriptor. GetProperties(G etType(Mesh)) '
MyBase.GetPrope rties(context, value, attributes)
End Function
Public Overrides Function GetPropertiesSu pported(ByVal context As
System.Componen tModel.ITypeDes criptorContext) As Boolean
Return True
End Function
End Class
I am new to this typeconverter stuff. My class property looks like
this:
<TypeConverter( GetType(MeshCon verter))> _
Public Property Mesh() As Direct3D.Mesh
Get
Return _mesh
End Get
Set(ByVal value As Direct3D.Mesh)
_mesh = value
End Set
End Property
This is the property I want to be able to view and edit within the
propertygrid when I pass the propertygrid my main class.
Can anybody see what I am doing wrong?
Thanks,
Richy