How is your designer creating the components? In my wizard control (which creates WizardPages, much like TabPages), the WizardPages are declared WithEvents.
My designer creates them like this:
vb.net Code:
Friend Sub OnAddPanel(ByVal sender As Object, ByVal e As EventArgs)
'Store oldpages for 'undo'
Dim oldPages As Control.ControlCollection = HostControl.Controls
RaiseComponentChanging(TypeDescriptor.GetProperties(HostControl)("Pages"))
'Create page using DesignerHost
Dim P As WizardPage = DirectCast(DesignerHost.CreateComponent(GetType(WizardPage)), WizardPage)
P.Title = P.Name
P.IsWelcomePage = False
P.IsLastPage = False
HostControl.Pages.Add(P)
RaiseComponentChanged(TypeDescriptor.GetProperties(HostControl)("Pages"), oldPages, HostControl.Pages)
HostControl.SelectedPage = P
SetVerbs()
End Sub
where DesignerHost is:
vb.net Code:
Public ReadOnly Property DesignerHost() As IDesignerHost
Get
If m_DesignerHost Is Nothing Then
m_DesignerHost = DirectCast(GetService(GetType(IDesignerHost)), IDesignerHost)
End If
Return m_DesignerHost
End Get
End Property
I tried changing the whole 'CreateComponent' stuff to simply creating a new instance (Dim P As New WizardPage) but that screws the whole control over; it seems it doesn't create the component at all then...