Question Object SubProperty

bufer24

Active member
Joined
Mar 27, 2008
Messages
35
Programming Experience
3-5
I am solving a following issue: I want to create a usercontrol with properties of custom type. These properties have another properties of custom type. I found many examples of implementing such situation, but none of them seems to work properly. A change of the property value in property grid at design time does nothing. The change becomes apparent only after starting the application. Here´s the example:

VB.NET:
Imports System.ComponentModel

Public Class UC
    Dim _c As New MyProp1

    Public Property c() As MyProp1
        Get
            Return _c
        End Get
        Set(ByVal value As MyProp1)
            _c = value
            lbl.Text = c.b.a
        End Set
    End Property

    Public Sub New()
        InitializeComponent()
        lbl.Text = c.b.a
    End Sub

    <TypeConverter(GetType(ExpandableObjectConverter))> _
    Public Class MyProp1
        Dim _b As New MyProp2

        Public Property b() As MyProp2
            Get
                Return _b
            End Get
            Set(ByVal value As MyProp2)
                _b = value
            End Set
        End Property
    End Class

    <TypeConverter(GetType(ExpandableObjectConverter))> _
    Public Class MyProp2
        Dim _a As Integer = 2

        Public Property a() As Integer
            Get
                Return _a
            End Get
            Set(ByVal value As Integer)
                _a = value
            End Set
        End Property
    End Class
End Class

the usercontrol has only a label which outputs the property value. I can see the property in the propertygrid but when I change the value, it doesn´t change at design-time. It becomes changed only after I start the application.
How to make it change at design-time?
 
Top Bottom