all groups > dotnet windows forms designtime > august 2004 >
You're in the

dotnet windows forms designtime

group:

Problem with Collection/Property in Usercontrol



Problem with Collection/Property in Usercontrol Marc Fauser
8/6/2004 12:03:10 PM
dotnet windows forms designtime: 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

Re: Problem with Collection/Property in Usercontrol Paul
8/9/2004 5:16:49 PM
Try to write the following:

<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel
..DesignerSerializationVisibility.Content)> _

Public Property Buttons() As myTBButtons

......



[quoted text, click to view]

AddThis Social Bookmark Button