473,396 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Preload combo with items

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

Nov 13 '06 #1
3 1825
You can check DesignMode and then create them or not based on when you decide
to create them

"Lee" wrote:
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

Nov 13 '06 #2
Lee wrote:
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

Nov 13 '06 #3
Lee
Sorry,

You are right, I'm being an arse.

Lee
Jay Riggs wrote:
Lee wrote:
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
Nov 14 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Bob | last post by:
I usually use some "pre-load" code in my pages to preload graphics that will be swapped. But, I'm thinking that rather than the long, repetitive, once, for each graphic hardcoded stuff like this: ...
2
by: Nikolay Petrov | last post by:
I have asked a question before some time, and a guy responded to it. His answer raised new questions and I replied them back, but still no answer. I need them urgently so I am to post the whole...
2
by: http://www.visual-basic-data-mining.net/forum | last post by:
Hi... Say i have this string call "data" in Form1, this string contains number "5" value.... how do i pass this string to the Form2 and compare with the combo box items... The combo box ...
2
by: Dave | last post by:
>From a combo box the user can select a supplier. They then click the order button and are then taken to the orders page. From here comes the problem, I want the user to select a combo box unique...
9
by: cocacrispy | last post by:
I've read many forum posts and articles and haven't made any headway with this. Let me describe my tables and when I'm trying to do and see if any one can help me. I have an items table, a...
6
by: =?Utf-8?B?amVmZmVyeQ==?= | last post by:
i need help with a combo box and this same code works on my first tab with a combo box. The error or problem i have is this code causes an index out of range error when i run it on my second combo...
1
by: Josephbupe | last post by:
Sorry, i didn't know exactly what to name my question. What i need is to create a database for storing office items that will include Desktop computers, Laptops, printers, phones, etc. as...
2
by: mygirl22 | last post by:
Hi, I used this code to created 2 combo boxes General and Specific...and Only show Specific (Combo B) when Combo A is chosen..... What i need now is to know how to assign specific values to the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.