M
Mark Peters
I have a control class that inherits from ComboBox. The intention of the constructor is to grab a reference to the BaseForm class of the form containing the custom control and populate its members using cached data from a "ClientCache" dataset in the base form. The constructor:
Public Sub New()
Me.Name = "cboItems"
Dim bf As BaseForm = CType(Me.FindForm(), BaseForm)
Me.DataSource = bf.ClientCache.Tables("MyItems")
End Sub
The code always dies on line 3 because Me.FindForm() always returns Nothing, even though the combobox control is being used by a windows form. (All our forms inherit from BaseForm, which inherits Windows.Form.)
VS.NET help indicates that FindForm "retrieves the form that the control is on". But from all indications this is not the case.
Thoughts?
TIA.
Mark
Public Sub New()
Me.Name = "cboItems"
Dim bf As BaseForm = CType(Me.FindForm(), BaseForm)
Me.DataSource = bf.ClientCache.Tables("MyItems")
End Sub
The code always dies on line 3 because Me.FindForm() always returns Nothing, even though the combobox control is being used by a windows form. (All our forms inherit from BaseForm, which inherits Windows.Form.)
VS.NET help indicates that FindForm "retrieves the form that the control is on". But from all indications this is not the case.
Thoughts?
TIA.
Mark