Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / August 2004

Tip: Looking for answers? Try searching our database.

Problem with Collection/Property in Usercontrol

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Marc Fauser - 06 Aug 2004 11:03 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.