473,796 Members | 2,632 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1847
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
1747
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: var bb_off = new Image(); bb_off.src = "images/bb_off.jpg"; ....that I could have an array where I just listed the names of the graphics, a loop, and code in the loop that cycles through each entry in the array to create and pre-load the "on"...
2
355
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 thing again. I've found that nobody looks at the older threads ;-( My Question was: I have a Combo box, binded to a dataset With cmbCompany .DataSource = dsSpecContact .DisplayMember = "Companies.CompanyName"
2
3713
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 DropDownStyle is set to DropDownList... which means when i pass, the SelectedIndex must be subtract or add by 1 to
2
311
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 to the supplier. Currently the combo boxes I create show all records for every supplier.
9
2433
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 vendors table, and a vendorItems table. The primary keys are ItemID, (ItemID, VendorID), and VendorID respectively. vendorItems is a join table, facilitating a many-to-many relationship between vendors and items. I've built a form for entering data on...
6
1875
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 box: (errored code) Select Case ComboBox2.text Case Is ="Execute Program" 'code to execute program here Case Is ="Other Command that executes code at a certain time" ' code below the same as above except that it works But not my first(this...
1
1325
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 ItemCategories. I have a combo box on form to list all ItemCategories and run query by Item Category. Then the query result should show all the items, if say ItemCategory was Desktop computers then items returned by query will be all desktop computers. ...
2
5073
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 items in combo b (Specific).??? If i chose a sode, Fanta, i want the total price to be $20.00 (this price will show up in the finial price box....Please Help!! drinkComboBox.Items.Clear() 'Clears the old items out of the drinkComboBox ...
0
9680
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9528
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10455
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10173
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7547
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6788
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4116
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.