OK, in your PageCollection class, add a member variable: Private _parentUserControl As UserControland change the constructor of the PageCollection as well: Public Sub New(parent As UserControl)
_parentUserControl = parent
End SubThis will store the control that the class is going to be used with, thus
exposing its Control collection. Now, change the Add method: Public Function Add(ByVal Item As Panel) As Integer
_parentUserControl.Controls.Add(Item)
Return List.Add(Item)
End FunctionThat will add the panel to the UserControl. Finally, you need to
change the constructor of the PageList class: Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
SetStyle(ControlStyles.AllPaintingInWmPaint, True)
SetStyle(ControlStyles.DoubleBuffer, True)
_pagecollection = New PageCollection(Me) '<-- I added the [b]Me[/b] parameter here,
'so the current UserControl will be passed to the PageCollection.
End Sub