Hi,

I am trying to create a UserControl that mimics the Options screen from the Visual Studio (2008) IDE and many other programs: a list of all the 'sub-options' which give you the corresponding options when selected.
My idea was that it worked pretty much the same as a TabControl except that the 'tab headers' are now the list entries and the tabpages are simple Panels that get hidden/unhidden when they are needed.

Now, I want the user to be able to add options panels (or "Pages") from the designer so he doesn't have to do it via code obviously.

I created a Public Property called Pages() of type "Collection" that will hold the Pages (which are of another UserControl control type called "ctrlPage", inherited from the Panel control).

I can access this property from the designer, but I can only add 'Objects'. How can I specify that these Pages are actually of the type "ctrlPage" instead of just Object?

I have tried replacing the Collection with a "List(Of ctrlPage)" but that keeps giving me an error about Panels and ctrlPage not being serializable or something...


The pages property is just this:
Private _Pages As Collection

vb.net Code:
  1. Public Property Pages() As Collection
  2.         Get
  3.             If _Pages Is Nothing Then _Pages = New Collection()
  4.             Return _Pages
  5.         End Get
  6.         Set(ByVal value As Collection)
  7.             _Pages = value
  8.         End Set
  9.     End Property