I want to use a collection of controls in a usercontrol. It should work like
the built-in toolbar, that means i want to add and remove buttons with the
designer.
my problem is that the designer does not save settings within my
collection - the entries stay in the generated code but when i run the
project or reload the source my property shows up empty.
I also noticed that I would need a 'add' the individual buttons to the
collection in the generated code but i have no idea how to manage this.
Why doesn't the designer store my collection and how do I inject custom code
when editing my collection?
Thanks,
Thomas
Public Class MyTbButton
Inherits System.Windows.Forms.UserControl
'...
End Class
Public Class MyToolbar
Inherits System.Windows.Forms.UserControl
#Region "xyz"
'...
'
'MyToolbar
'
Me.BackColor = System.Drawing.Color.Yellow
Me.Name = "MyToolbar"
Me.Size = New System.Drawing.Size(576, 150)
'...
#End Region
Public Class myTBButtons
Inherits System.Collections.CollectionBase
Public Property Item(ByVal Index As Integer) As MyTbButton
Get
Return CType(list.Item(Index), MyTbButton)
End Get
Set(ByVal Value As MyTbButton)
list.Item(Index) = Value
End Set
End Property
End Class
Private pButtons As New myTBButtons
Public Property Buttons() As myTBButtons
Get
Return pButtons
End Get
Set(ByVal Value As myTBButtons)
pButtons = Value
End Set
End Property
End Class
Paul - 09 Aug 2004 14:16 GMT
Try to write the following:
<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel
.DesignerSerializationVisibility.Content)> _
Public Property Buttons() As myTBButtons
.....
> I want to use a collection of controls in a usercontrol. It should work like
> the built-in toolbar, that means i want to add and remove buttons with the
[quoted text clipped - 60 lines]
> End Property
> End Class