My question is why the designer does not store DesignTime values in case of using Structure instead of Class.
Here is my code
<TypeConverter(GetType(ExpandableObjectConverter))>
Public Structure ABC
Public Property Prop1 As Integer
Public Property Prop2 As String
Public Property Prop3 As Boolean
Public Overrides Function ToString() As String
Return Prop2
End Function
End Structure
<TypeConverter(GetType(ExpandableObjectConverter))>
Public Class XYZ
Public Property Prop1 As Integer
Public Property Prop2 As String
Public Property Prop3 As Boolean
Public Overrides Function ToString() As String
Return Prop2
End Function
End Class
Public Class MyControl
Inherits Control
<DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
Public ReadOnly Property ABCs As New ObjectModel.Collection(Of ABC)
<DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
Public ReadOnly Property XYZs As New ObjectModel.Collection(Of XYZ)
Protected Overrides Sub OnClick(e As EventArgs)
For Each a As ABC In ABCs
Debug.WriteLine("ABC :" & a.Prop2)
Next
For Each x As XYZ In XYZs
Debug.WriteLine("XYZ :" & x.Prop2)
Next
End Sub
End Class
The designer only stores XYZs values and can not store ABCs
Here is the designer code
'MyControl1
'
Me.MyControl1.BackColor = System.Drawing.Color.WhiteSmoke
Me.MyControl1.ForeColor = System.Drawing.Color.Gray
Me.MyControl1.Location = New System.Drawing.Point(150, 216)
Me.MyControl1.Name = "MyControl1"
Me.MyControl1.Size = New System.Drawing.Size(182, 123)
Me.MyControl1.TabIndex = 2
Me.MyControl1.Text = "MyControl1"
Xyz1.Prop1 = 0
Xyz1.Prop2 = "Test"
Xyz1.Prop3 = False
Me.MyControl1.XYZs.Add(Xyz1)