Cannot access "Items" collection of custom control inside another custom control

Omid Golban

Member
Joined
Jun 3, 2003
Messages
6
I based my custom control "cEzComboBox" on a combo box and added a couple of my own properties:
Imports System.ComponentModel
Public Class cEzComboBox
Inherits System.Windows.Forms.ComboBox
.... added some more properties of my own ....

Then I created another (parent) control "cEzLblCbo" that contains the above control "cEzComboBox" as well as few other ones.
Public Class cEzLblCbo
Inherits System.Windows.Forms.UserControl
....
#Region " Windows Form Designer generated code "
....
Friend WithEvents EzCbo As EzFormControls.cEzComboBox

I can add both the child control and the parent control onto a form in my application.
Then I will have access to "items" collection of the child control, but will not in the parent control:
#Region " Windows Form Designer generated code "
....
child control
Friend WithEvents MyEzComboBox1 As EzFormControls.cEzComboBox
parent control
Friend WithEvents ezlblcboCono As EzFormControls.cEzLblCbo
....

I can then use the "Items" collection in this child control:
CEzComboBox1.Items.Add("Test")

But I cannot access the "Items" collection of the child control within this parent control:
ezlblcboCono.EzCbo.items.add("Test")
The error is: EzFormControls.cEzLblCbo.Protected Overridable Property EzCbo() As EzFormControls.cEzComboBox is not accessible in this context because it is Protected.

How can I use the items collection of the child control within this parent control?

Thank you,
Omid
 
Back
Top