PropertyGrid: Objects with subproperties

jviper

Member
Joined
Nov 24, 2005
Messages
12
Programming Experience
1-3
I am having a problem with objects that have other objects as properties on a property grid. Now when I display ths object clsPropsFrame on the property grid, everything shows up as expected, except when I try to edit the x,y,or z of location which is of type clsPropsVec3, it ignores the change. What's strange is that when I type the vector in as a string (like "0,16,0"), it changes. I have the following code:

VB.NET:
'//////////////////Object Component///////////////////////////

<TypeConverter(GetType(ExpandableObjectConverter))> _
    Public Class clsPropsVec3
        Inherits ExpandableObjectConverter
        Private refvec As TV_3DVECTOR
        Public Sub New()
            refvec = New TV_3DVECTOR(0, 0, 0)
        End Sub
        Public Sub New(ByVal vec As TV_3DVECTOR)
            refvec = New TV_3DVECTOR(vec.x, vec.y, vec.z)
        End Sub
        Public Shared Widening Operator CType(ByVal Vec As TV_3DVECTOR) As clsPropsVec3
            Return New clsPropsVec3(Vec)
        End Operator
        Public Shared Widening Operator CType(ByVal props As clsPropsVec3) As TV_3DVECTOR
            Return props.refvec
        End Operator
        Public Property X() As Single
            Get
                Return refvec.x
            End Get
            Set(ByVal value As Single)
                refvec.x = value
            End Set
        End Property
        Public Property Y() As Single
            Get
                Return refvec.y
            End Get
            Set(ByVal value As Single)
                refvec.y = value
            End Set
        End Property
        Public Property Z() As Single
            Get
                Return refvec.z
            End Get
            Set(ByVal value As Single)
                refvec.z = value
            End Set
        End Property
        Public Overrides Function ToString() As String
            Return Strings.Format(refvec.x, "0.0") + ", " + Strings.Format(refvec.y, "0.0") + ", " + Strings.Format(refvec.z, "0.0")
        End Function
        Public Overloads Overrides Function CanConvertFrom(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal sourceType As System.Type) As Boolean
            If (sourceType.Equals(GetType(String))) Then
                Return True
            ElseIf (sourceType.Equals(GetType(clsPropsVec3))) Then
                Return True
            Else
                Return MyBase.CanConvertFrom(context, sourceType)
            End If
        End Function
        Public Overloads Overrides Function CanConvertTo(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal destinationType As System.Type) As Boolean
            If (destinationType.Equals(GetType(String))) Then
                Return True
            ElseIf (destinationType.Equals(GetType(clsPropsVec3))) Then
                Return True
            Else
                Return MyBase.CanConvertTo(context, destinationType)
            End If
        End Function
        Public Overloads Overrides Function ConvertFrom(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal culture As System.Globalization.CultureInfo, ByVal value As Object) As Object
            If (TypeOf value Is String) Then
                Dim txt As String = CType(value, String)
                Dim fields() As String = txt.Split(CChar(","))
                Try
                    Return New clsPropsVec3(New TV_3DVECTOR(CSng(fields(0)), CSng(fields(1)), CSng(fields(2))))
                Catch
                    Throw New InvalidCastException(CStr(value))
                End Try
            ElseIf (TypeOf value Is TV_3DVECTOR) Then
                Return DirectCast(value, clsPropsVec3)
            Else
                Return MyBase.ConvertFrom(context, culture, value)
            End If
        End Function
        Public Overloads Overrides Function ConvertTo(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal culture As System.Globalization.CultureInfo, ByVal value As Object, ByVal destinationType As System.Type) As Object
            If (destinationType.Equals(GetType(String))) Then
                Return value.ToString()
            ElseIf (destinationType.Equals(GetType(clsPropsVec3))) Then
                Return DirectCast(value, clsPropsVec3)
            Else
                Return MyBase.ConvertTo(context, culture, value, destinationType)
            End If
        End Function
        Public Overloads Overrides Function GetPropertiesSupported(ByVal context As ITypeDescriptorContext) As Boolean
            Return True
        End Function
        Public Overloads Overrides Function GetProperties(ByVal context As ITypeDescriptorContext, ByVal value As Object, ByVal Attribute() As Attribute) As PropertyDescriptorCollection
            Return TypeDescriptor.GetProperties(value)
        End Function
    End Class

    '///////////////Object Code//////////////////

    <TypeConverter(GetType(ExpandableObjectConverter))> _
    Public Class clsPropsFrame
        Private refFrame As clsFrame
        Public Changable As Boolean
        Public Sub New(ByVal Frame As clsFrame, ByVal bolChangable As Boolean)
            refFrame = Frame
            Changable = bolChangable
        End Sub
        <ParenthesizePropertyName(True)> _
        <Category("Design")> _
        Public Property Name() As String
            Get
                If refFrame Is Nothing Then Return "<No Frame>"
                Return refFrame.Name
            End Get
            Set(ByVal value As String)
                If refFrame Is Nothing Then Exit Property
                If Not Changable Then Exit Property
                refFrame.Name(True) = value
            End Set
        End Property
        <Category("Design")> _
        Public Property Index() As Integer
            Get
                If refFrame Is Nothing Then Return -1
                Return refFrame.Index
            End Get
            Set(ByVal value As Integer)
                If refFrame Is Nothing Then Exit Property
                If Not Changable Then Exit Property
                refFrame.Index(True) = value
                clsFrame.SortByIndex()
            End Set
        End Property
        <Category("Layout")> _
        <TypeConverter(GetType(clsPropsVec3))> _
        Public Property Location() As clsPropsVec3
            Get
                If refFrame Is Nothing Then Return New TV_3DVECTOR(Single.NaN, Single.NaN, Single.NaN)
                Return refFrame.Position(False)
            End Get
            Set(ByVal value As clsPropsVec3)
                If refFrame Is Nothing Then Exit Property
                If Not Changable Then Exit Property
                refFrame.Position(False) = value
            End Set
        End Property
        Public Overrides Function ToString() As String
            Return "Frame {" + refFrame.Name + "}"
        End Function
        Public Sub Destroy()
            refFrame = Nothing
            Finalize()
          End Sub
    End Class

I noticed that when I changed a component of clsPropsVec3, the property change in clsPropsFrame does not get executed. I tried making it fire of an event when a component is changed in clsPropsVec3, with the following additional code:

VB.NET:
Public Property X() As Single
            Get
                Return refvec.x
            End Get
            Set(ByVal value As Single)
                refvec.x = value
                ---------> RaiseEvent ValueChanged()
            End Set
        End Property

VB.NET:
Public Class clsPropsFrame
        Private refFrame As clsFrame
       ------> private WithEvents vecPosition as clsPropsVec3

VB.NET:
Public Sub New(ByVal Frame As clsFrame, ByVal bolChangable As Boolean)
            refFrame = Frame
            --------> If Not (refFrame is Nothing) Then
            --------> vecPosition = New clsPropsVec3(refFrame.Position(False))
            --------> End If
            Changable = bolChangable
        End Sub

VB.NET:
Public Sub OnPositionChange() handles vecPosition.ValueChanged
             Location = vecPosition
          End Sub

but for some reason it ever fires off the ValueChanged event

So how can I make the sub properties of clsPropsVec3 work?
 
The code is messy, you haven't posted all relevant classes, and you haven't explained the relationship between them. Without seeing all the code I'd say there is a chance it could work if you have set Changable to True.
If Not Changable Then Exit Property
but for some reason it ever fires off the ValueChanged event
Remember that when converting a string to the object a new instance is created, so you are probably not listening for the right object, not that you are in the first place.
--------> vecPosition = New clsPropsVec3(refFrame.Position(False))
I copied your classes and removed everything that didn't make sense and ended up with these three classes:
VB.NET:
Public Class TV_3DVECTOR

    Public Sub New(ByVal x As Single, ByVal y As Single, ByVal z As Single)
        Me.X = x
        Me.Y = y
        Me.Z = z
    End Sub
    Private _X, _Y, _Z As Single
    Public Property X() As Single
        Get
            Return Me._X
        End Get
        Set(ByVal value As Single)
            Me._X = value
        End Set
    End Property
    Public Property Y() As Single
        Get
            Return Me._Y
        End Get
        Set(ByVal value As Single)
            Me._Y = value
        End Set
    End Property
    Public Property Z() As Single
        Get
            Return Me._Z
        End Get
        Set(ByVal value As Single)
            Me._Z = value
        End Set
    End Property

    Public Overrides Function ToString() As String
        Return String.Format("{0:0.0}; {1:0.0}; {2:0.0}", Me.X, Me.Y, Me.Z)
    End Function
End Class
Notice also I changed the value separator to ";" to not conflict different cultures decimal separator.
VB.NET:
Imports System.ComponentModel

Public Class Vec3Converter
    Inherits ExpandableObjectConverter
  
    Public Overloads Overrides Function CanConvertFrom(ByVal context As ITypeDescriptorContext, ByVal sourceType As System.Type) As Boolean
        If (sourceType.Equals(GetType(String))) Then
            Return True
        ElseIf (sourceType.Equals(GetType(Vec3Converter))) Then
            Return True
        Else
            Return MyBase.CanConvertFrom(context, sourceType)
        End If
    End Function

    Public Overloads Overrides Function CanConvertTo(ByVal context As ITypeDescriptorContext, ByVal destinationType As System.Type) As Boolean
        If (destinationType.Equals(GetType(String))) Then
            Return True
        ElseIf (destinationType.Equals(GetType(Vec3Converter))) Then
            Return True
        Else
            Return MyBase.CanConvertTo(context, destinationType)
        End If
    End Function

    Public Overloads Overrides Function ConvertFrom(ByVal context As ITypeDescriptorContext, ByVal culture As System.Globalization.CultureInfo, ByVal value As Object) As Object
        If (TypeOf value Is String) Then
            Dim txt As String = CType(value, String)
            Dim fields() As String = txt.Split(";"c)
            Try
                Return New TV_3DVECTOR(CSng(fields(0)), CSng(fields(1)), CSng(fields(2)))
            Catch
                Throw New InvalidCastException(CStr(value))
            End Try
        ElseIf (TypeOf value Is TV_3DVECTOR) Then
            Return DirectCast(value, Vec3Converter)
        Else
            Return MyBase.ConvertFrom(context, culture, value)
        End If
    End Function

    Public Overloads Overrides Function ConvertTo(ByVal context As ITypeDescriptorContext, ByVal culture As System.Globalization.CultureInfo, _
   ByVal value As Object, ByVal destinationType As System.Type) As Object
        If (destinationType.Equals(GetType(String))) Then
            Return value.ToString()
        ElseIf (destinationType.Equals(GetType(Vec3Converter))) Then
            Return DirectCast(value, Vec3Converter)
        Else
            Return MyBase.ConvertTo(context, culture, value, destinationType)
        End If
    End Function

    Public Overloads Overrides Function GetPropertiesSupported(ByVal context As ITypeDescriptorContext) As Boolean
        Return True
    End Function

    Public Overloads Overrides Function GetProperties(ByVal context As ITypeDescriptorContext, ByVal value As Object, ByVal Attribute() As Attribute) As PropertyDescriptorCollection
        Return TypeDescriptor.GetProperties(value)
    End Function
 
End Class
VB.NET:
Imports System.ComponentModel

Public Class Frame

    Public Changable As Boolean
    Public Sub New(ByVal bolChangable As Boolean)
        Me.Changable = bolChangable
    End Sub
    Public Sub New(ByVal bolChangable As Boolean, ByVal vec As TV_3DVECTOR)
        Me.Changable = bolChangable
        Me.vecPosition = vec
    End Sub

    Private _name As String = "<No Frame>"
    <ParenthesizePropertyName(True)> _
    <Category("Design")> _
    Public Property Name() As String
        Get
            Return Me._name
        End Get
        Set(ByVal value As String)
            If Not Changable Then Exit Property
            Me._name = value
        End Set
    End Property

    Private _index As Integer = -1
    <Category("Design")> _
    Public Property Index() As Integer
        Get
            Return Me._index
        End Get
        Set(ByVal value As Integer)
            If Not Changable Then Exit Property
            Me._index = value
        End Set
    End Property

    Private vecPosition As New TV_3DVECTOR(Single.NaN, Single.NaN, Single.NaN)
    <Category("Layout")> _
    <TypeConverter(GetType(Vec3Converter))> _
    Public Property Location() As TV_3DVECTOR
        Get
            Return Me.vecPosition
        End Get
        Set(ByVal value As TV_3DVECTOR)
            If Not Changable Then Exit Property
            Me.vecPosition = value
        End Set
    End Property

    Public Overrides Function ToString() As String
        Return "Frame {" + Me.Name + "}"
    End Function

End Class
Now you can copy them and try out this code:
VB.NET:
Me.PropertyGrid1.SelectedObject = New Frame(True, New TV_3DVECTOR(1.0!, 2.0!, 3.0!))
Then you can mess everything up again :D
 
Well, I suppose I will have to clarify a bit.

The TV_3DVECTOR I did not write. I do not have control of TV_3DVECTOR. I do not have access to the code in TV_3DVECTOR. I think that problebly TV_3DVECTOR is not designed to be displayed on a property grid, because when I try to display it, all it shows is TV_3DVECTOR, and it is not expandable. So I tried writing a converter class so that I can get TV_3DVECTOR to display. I do this through the class clsPropsVec3. You could say that I am "wrapping" TV_3DVECTOR in clsPropsVec3.

The clsFrame class I did not write. I do not have control of clsFrame. I do not have access to the code in clsFrame. I think that problebly clsFrame is not designed to be displayed on a propertygrid. clsFrame contains properties of type TV_3DVECTOR, but I cannot edit them when I am displaying a clsFrame in the property grid. So I tried writting a converter class so that the properties in clsFrame of type TV_3DVECTOR will expand and I can edit them. This is done through clsPropsFrame. So essentially, clsPropsFrame contains properties of type clsPropsVec3 where clsFrame contains properties of type TV_3DVECTOR. You could say that I am "wrapping" clsFrame in clsPropsFrame.

The variable "Changable" is actually irrelevent in this case. I used this only to make some instances of clsFrame unchangable.

Now the only problem I'm having with the code above is that changes I make to a property in clsPropsFrame of type clsPropsVec3 are ignored. For example: I set the property grid object to a clsPropsFrame instance. I see a property in clsPropsFrame called "Location" of type clsPropsVec3. I expand it, and edit its "Y" component. So if the Y component was initialliy 0, and I change it to 8, when I press enter, it changes back to 0. This has nothing to do with the variable "Changable", is it is set to true when I do this.

So what I want to be able to do it expand a property in clsPropsFrame of type clsPropsVec3, and be able to edit that property by changing properties in clsPropsVec3. Is this possible?
 
Last edited:
Let's say my classes TV_3DVECTOR and Frame is the classes you can't change, and that the Location property does not have a converter, but you want to apply it. What you do then is to inherit the Frame class and Shadow the Location property where you apply the TypeConverter attribute. Example:
VB.NET:
Public Class CustomFrame
    Inherits Frame

    Public Sub New(ByVal vec As TV_3DVECTOR)
        MyBase.New(vec)
    End Sub

    <TypeConverter(GetType(Vec3Converter))> _
    <Category("Layout")> _
    Public Shadows Property Location() As TV_3DVECTOR
        Get
            Return MyBase.Location
        End Get
        Set(ByVal value As TV_3DVECTOR)
            MyBase.Location = value
        End Set
    End Property
End Class
Then you use the CustomFrame class instead of the Frame class that didn't have functionality you needed.
VB.NET:
Me.PropertyGrid1.SelectedObject = New CustomFrame(New TV_3DVECTOR(1.0!, 2.0!, 3.0!))
(Changable is ignored in this example)

If the property is overridable then override it instead of shadowing it.
 
Ah, I'll try that. And maybe this way I don't have to use delegates, which is what I recently tried and acually got to work, but worried about memory consumption.
 
Hmmmm, well this didn't seem to help :(

I now have the following code:

VB.NET:
'//////////////////////////////////// Vector Class ////////////////////////////////////////

    <TypeConverter(GetType(ExpandableObjectConverter))> _
    Public Class clsPropsVec3
        Private _x As Single
        Private _y As Single
        Private _z As Single
        Public Sub New(ByVal sngx As Single, ByVal sngy As Single, ByVal sngz As Single)
            _x = sngx
            _y = sngy
            _z = sngz
        End Sub
        Public Shared Widening Operator CType(ByVal props As clsPropsVec3) As TV_3DVECTOR
            Return New TV_3DVECTOR(props._x, props._y, props._z)
        End Operator
        Public Shared Widening Operator CType(ByVal vec As TV_3DVECTOR) As clsPropsVec3
            Return New clsPropsVec3(vec.x, vec.y, vec.z)
        End Operator
        Public Property X() As Single
            Get
                Return _x
            End Get
            Set(ByVal value As Single)
                _x = value
            End Set
        End Property
        Public Property y() As Single
            Get
                Return _y
            End Get
            Set(ByVal value As Single)
                _y = value
            End Set
        End Property
        Public Property z() As Single
            Get
                Return _z
            End Get
            Set(ByVal value As Single)
                _z = value
            End Set
        End Property
        Public Overrides Function ToString() As String
            Return Strings.Format(_x, "0.0") + "; " + Strings.Format(_y, "0.0") + "; " + Strings.Format(_z, "0.0")
        End Function
    End Class

    '///////////////////////// Frame class ////////////////////////////////////

    Public Class clsPropsFrame
        Inherits clsFrame
        Private refFrame As clsFrame
        Public Changable As Boolean
        Public Sub New(ByVal Frame As clsFrame, ByVal bolChangable As Boolean)
            MyBase.New(Frame)
            refFrame = Frame
            Changable = bolChangable
        End Sub
        <ParenthesizePropertyName(True)> _
        <Category("Design")> _
        Public Shadows Property Name() As String
            Get
                If refFrame Is Nothing Then Return "<No Frame>"
                Return refFrame.Name
            End Get
            Set(ByVal value As String)
                If refFrame Is Nothing Then Exit Property
                If Not Changable Then Exit Property
                refFrame.Name(True) = value
            End Set
        End Property
        <Category("Design")> _
        Public Shadows Property Index() As Integer
            Get
                If refFrame Is Nothing Then Return -1
                Return refFrame.Index
            End Get
            Set(ByVal value As Integer)
                If refFrame Is Nothing Then Exit Property
                If Not Changable Then Exit Property
                refFrame.Index(True) = value
                clsFrame.SortByIndex()
            End Set
        End Property
        <Category("Layout")> _
        <TypeConverter(GetType(clsPropsVec3))> _
        Public Shadows Property Position() As TV_3DVECTOR
            Get
                If refFrame Is Nothing Then Return New TV_3DVECTOR(Single.NaN, Single.NaN, Single.NaN)
                Return refFrame.Position(False)
            End Get
            Set(ByVal value As TV_3DVECTOR)
                If refFrame Is Nothing Then Exit Property
                If Not Changable Then Exit Property
                refFrame.Position(False) = value
            End Set
        End Property
        Public Shadows Sub destroy()
            refFrame = Nothing
        End Sub
        Public Overrides Function ToString() As String
            Return "Frame {" + refFrame.Name + "}"
        End Function
    End Class

And I'm back to where it does not expand the tv_3vector property. It just shows tv_3dvector, and wont let me expand or edit it.
Hmmm, I suppose this may be a good time to mention that tv_3dvector is a structure and not a class. I could not inherit from it. Structures cannot inherit at all, and classes can only inherit from other classes. tv_3dvector is not an interface so I cannot implement from it.

So I tried changing the property to type clspropsvec3, and now it expands, but we are back to where it ignores the changes if I try to edit it by components.

Anything else I'm missing?
 
Hmmmm, well this didn't seem to help
That is only because you have not followed my advice.
I suppose this may be a good time to mention that tv_3dvector is a structure and not a class
I don't see how this information has any relevance? The proposed solution did not involve doing anything with the vector type.

Start with deleting all your classes as I have suggested. Then copy the Vec3Converter and CustomFrame classes I posted. Use the sample code to display a CustomFrame instance in a PropertyGrid. If your frame class is called "clsFrame" and not "Frame" then so change the CustomFrame inherits to reflect this. Apart from this you should not change anything and not add anything.

For ConvertTo type String the Vec3Converter uses the ToString method of the TV_3DVECTOR type, should this not return a satisfactory formatted string then instead just return the appropriate string directly from the converter, for example:
VB.NET:
If (destinationType.Equals(GetType(String))) Then
    Dim v As TV_3DVECTOR = CType(value, TV_3DVECTOR)
    Return String.Format("{0:0.0}; {1:0.0}; {2:0.0}", v.X, v.Y, v.Z)
 
Ok, tried the code. It atleast now shows somthing relevent for Location, but I still cannot expand it or edit it. If I try to type it in directly, it ignores the change.

Note clsFrame does not have a contructor that accepts a TV_3DVECTOR, so I had to use what was given. I was told there was a contructor that simply copied the contents of the passed clsFrame. So that is the one I used. Also note the Position property in clsFrame has arguments. The first argument is not optional. It's for localspace (false) vs worldspace (true).

I have the following code now:
VB.NET:
<TypeConverter(GetType(ExpandableObjectConverter))> _
    Public Class Vec3Converter
        Inherits ExpandableObjectConverter
        Public Overloads Overrides Function CanConvertFrom(ByVal context As ITypeDescriptorContext, ByVal sourceType As System.Type) As Boolean
            If (sourceType.Equals(GetType(String))) Then
                Return True
            ElseIf (sourceType.Equals(GetType(Vec3Converter))) Then
                Return True
            Else
                Return MyBase.CanConvertFrom(context, sourceType)
            End If
        End Function
        Public Overloads Overrides Function CanConvertTo(ByVal context As ITypeDescriptorContext, ByVal destinationType As System.Type) As Boolean
            If (destinationType.Equals(GetType(String))) Then
                Return True
            ElseIf (destinationType.Equals(GetType(Vec3Converter))) Then
                Return True
            Else
                Return MyBase.CanConvertTo(context, destinationType)
            End If
        End Function
        Public Overloads Overrides Function ConvertFrom(ByVal context As ITypeDescriptorContext, ByVal culture As System.Globalization.CultureInfo, ByVal value As Object) As Object
            If (TypeOf value Is String) Then
                Dim txt As String = CType(value, String)
                Dim fields() As String = txt.Split(";"c)
                Try
                    Return New TV_3DVECTOR(CSng(fields(0)), CSng(fields(1)), CSng(fields(2)))
                Catch
                    Throw New InvalidCastException(CStr(value))
                End Try
            ElseIf (TypeOf value Is TV_3DVECTOR) Then
                Return DirectCast(value, Vec3Converter)
            Else
                Return MyBase.ConvertFrom(context, culture, value)
            End If
        End Function
        Public Overloads Overrides Function ConvertTo(ByVal context As ITypeDescriptorContext, ByVal culture As System.Globalization.CultureInfo, _
       ByVal value As Object, ByVal destinationType As System.Type) As Object
            If (destinationType.Equals(GetType(String))) Then
                'Return value.ToString()
                Dim v As TV_3DVECTOR = CType(value, TV_3DVECTOR)
                Return String.Format("{0:0.0}; {1:0.0}; {2:0.0}", v.x, v.y, v.z)
            ElseIf (destinationType.Equals(GetType(Vec3Converter))) Then
                Return DirectCast(value, Vec3Converter)
            Else
                Return MyBase.ConvertTo(context, culture, value, destinationType)
            End If
        End Function
        Public Overloads Overrides Function GetPropertiesSupported(ByVal context As ITypeDescriptorContext) As Boolean
            Return True
        End Function
        Public Overloads Overrides Function GetProperties(ByVal context As ITypeDescriptorContext, ByVal value As Object, ByVal Attribute() As Attribute) As PropertyDescriptorCollection
            Return TypeDescriptor.GetProperties(value)
        End Function
    End Class




    Public Class clsPropsFrame
        Inherits clsFrame
        Public Sub New(ByVal ref As clsFrame)
            MyBase.New(ref)
        End Sub
        <TypeConverter(GetType(Vec3Converter))> _
        <Category("Layout")> _
        Public Shadows Property Location() As TV_3DVECTOR
            Get
                Return MyBase.Position(False)
            End Get
            Set(ByVal value As TV_3DVECTOR)
                MyBase.Position(False) = value
            End Set
        End Property
        Public Shadows Sub Destroy()
            Me.Finalize()
        End Sub
    End Class



     PropertyGrid.SelectedObject = New clsPropsFrame(Frame_Selected)    ' where Frame_Selected is the selected clsFrame

I've also discovered that TV_3DVECTOR does not contain properties, which I suppose is relevent, because if it does not have properties, the property grid wont display it at all.
Or does that matter? I'm not sure anymore.
 
Last edited:
I've also discovered that TV_3DVECTOR does not contain properties, which I suppose is relevent, because if it does not have properties, the property grid wont display it at all.
Sure, THAT is relevant! The solution is really simple, just define your own TV_3DVECTOR type that actually has properties, use for example the one I posted in post 2. Use this type for your Location property in inherited Frame class and for the converter, the Vec3Converter I posted will work just fine unmodified. If it is necessary to pass the TV_3DVECTOR information to the base class use the property set/get for this where you interact with MyBase.
 
If it is necessary to pass the TV_3DVECTOR information to the base class use the property set/get for this where you interact with MyBase.
Hmmm, does this mean I have to write a different tv_3dvector class for every property clsframe has that is of tv_3dvector? The location/position is not the only property of that type. I've tried writing the new tv_3dvector class in a general way and it ignores all changes. The only way i was able to get away with it is giving the new tv_3dvector class a delegate to invoke when one of it's components were changed. Is there any other way?
 
Last edited:
Hmmm, does this mean I have to write a different tv_3dvector class for every property clsframe has that is of tv_3dvector? The location/position is not the only property of that type.
No, but you do have to Override/Shadow all interface to it to route things to your own type/instance.
I've tried writing the new tv_3dvector class in a general way and it ignores all changes. The only way i was able to get away with it is giving the new tv_3dvector class a delegate to invoke when one of it's components were changed. Is there any other way?
I don't know what you mean by this. If a "tv3" goes into this frame, and is somehow changed there, then you will know when it comes back out, surely this will happen through the class interface (a method or property or event).
Is there any other way?
If you mean to this as whole, then not that I'm aware of. Apart from being some work I don't see any difficulties doing this.
 
Back
Top