Preload combo with items

  • Thread starter Thread starter Lee
  • Start date Start date
L

Lee

Hi,

I am wondering whether it is easily achievable to create a custom combo
box control which contains certain items preloaded.

Basically I have a form which will contains several combos, each of
which will contain the same items. Rather then iterating through each
combo as part of the form load I wanted the control to automatically
contain the items.

I tried creating a custom control and adding the code below to either
the constructor or the OnCreateEvent but this resulted in the combo
containing two instances of 'item1' and two of 'item2', because they
were added at design time and run-time.

this.Items.Add("Item1");
this.Items.Add("Item2");

Any assistance would be appreciated.

Lee
 
You can check DesignMode and then create them or not based on when you decide
to create them
 
Lee said:
Hi,

I am wondering whether it is easily achievable to create a custom combo
box control which contains certain items preloaded.

Basically I have a form which will contains several combos, each of
which will contain the same items. Rather then iterating through each
combo as part of the form load I wanted the control to automatically
contain the items.

I tried creating a custom control and adding the code below to either
the constructor or the OnCreateEvent but this resulted in the combo
containing two instances of 'item1' and two of 'item2', because they
were added at design time and run-time.

this.Items.Add("Item1");
this.Items.Add("Item2");

Any assistance would be appreciated.

Lee

Lee,

Why not use the standard ComboBox control and use the control's Items
property in the form designer?

Am I missing something here?

HTH
-Jay
 
Sorry,

You are right, I'm being an arse.

Lee


Jay said:
Lee,

Why not use the standard ComboBox control and use the control's Items
property in the form designer?

Am I missing something here?

HTH
-Jay
 
Back
Top