473,776 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Associate value with item in combobox

Hi,

in ASP .Net, I can associate a value with and item in a dropdown list, for
example when binding to a list of employees, I can store the employeeid as a
value associated with each name in in the list so I can use this later when
retrieving data from my database.

I am now trying to develop a Windows forms app (.Net 2.0) and can find how
to do this when using a combobox set to the dropdownlist style (assume this
is the control I should us). When adding items manually, I only get a list
of strings to add but nowhere to associate a value.

Can anyone please shed som light on how to do this in Windows forms ?

Thank you

Niclas
Apr 25 '06 #1
1 2134
Hi Niclas,

You can actually add objects (instances of classes) to the combobox, not
just strings, and the ToString() method will be used to show a text for the
object. The ComboBox has properties to retrieve the selected object, that
you can cast back to your class and retrieve the full object.
--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com
"Niclas" <li************ *@hotmail.com> escribió en el mensaje
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
Hi,

in ASP .Net, I can associate a value with and item in a dropdown list, for
example when binding to a list of employees, I can store the employeeid as
a value associated with each name in in the list so I can use this later
when retrieving data from my database.

I am now trying to develop a Windows forms app (.Net 2.0) and can find how
to do this when using a combobox set to the dropdownlist style (assume
this is the control I should us). When adding items manually, I only get a
list of strings to add but nowhere to associate a value.

Can anyone please shed som light on how to do this in Windows forms ?

Thank you

Niclas

Apr 25 '06 #2

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

Similar topics

6
2382
by: Ashok | last post by:
hi, i want to know how to make a specific type of file open in an application i developed in python when the user clicks on the file.(in windows) for eg. a .txt file when clicked opens in notepad, a .doc file when clicked opens in MS-word. In the same way i want to make a .xyz file open in the application i developed when clicked. thanks in advance for any advice.
1
9494
by: nickyw | last post by:
Hi, Can anyone help, I want to get a reference to a combobox item based on the item's value rather than the text (basically what I am asking is, is there a function like 'FindStringExact' for values) , does anyone know how to do this? Thanks, Nicky
0
4806
by: JSantora | last post by:
Essentially, InsertAT is broken! For the past couple of hours, I've been getting this "Parameter name: '-2147483550' is not a valid value for 'index'." error. Apparently, its caused by having manually inserted a row in the table bound to the Combo box. The InsertAt Method of adding a row just does not work. Hope this helps anyone with this problem. john
1
1181
by: Irfan | last post by:
hi, All I am trying to achieve a simple programming task ie; when the user selects an item from the comboBox ,the relevant data should be displayed in the grid. I am using Publisher & Titles tables of Biblo.mdb as an example, where in Publisher names are displayed in the cmbox and all the titles related to each are disaplyed in the grid.This is what i am doing but nothing is displayed in the grid . Can someone advise pl. 'fill the...
2
8673
by: shumaker | last post by:
I have a combobox that is very much like the one found in the RSS project here: http://msdn.microsoft.com/vstudio/express/visualCSharp/learning/ My projectNameComboBox basically is filled with a list of values from a table, and as the user selects values, a datagrid displays related records from another table because it is bound via FK relationship. My table: /****** Object: Table . Script Date: 06/19/2006
6
5650
by: Aussie Rules | last post by:
Hi, I have a datepicker that show a calender. The user picks a date and the time component is always 00:00. I then have a drop down that provides a list of times, (10:00, 11:00 etc), and I want to combine this with the date value, so that I can store it in a single field in the database. How can I combine these two values into one ?
1
3681
by: Saww | last post by:
Hello lately i have been trying to make a custom combobox with a few targets. 1. to create a disabled items 2. to create a seperator item I already managed both properties items. i also managed to draw both items as i want(disabled in gray, seperator as a line). the problem is the user can click on the items, both the line(since it's actually a '-' item) of the seperator item, and the disabled item. i know i should overrides the WndProc...
7
3582
by: Brad Pears | last post by:
I have something strange going on - pretty sure it used to work before - and now it does not... Why does the following code not clear a combo box? Me.cboLocation.Text = String.Empty OR Me.cboLocation.Text = ""
2
14773
by: =?Utf-8?B?RHJEQkY=?= | last post by:
I understand that the Value put into a DataGridViewComboBoxCell has to be a member of the Items list or an exception is thrown. I also understand that you can override that exception by handling the DataError event and just doing nothing in the circumstance that caused the error. Here's my situation: I would like to allow the user to EITHER select an item from the ComboBox (in a DataGridView) OR type in a new value of their own.
0
9628
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
9464
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
10292
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...
0
9923
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8954
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7471
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
6722
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();...
1
4031
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
2
3627
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.