473,378 Members | 1,066 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,378 software developers and data experts.

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 2116
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****************@TK2MSFTNGP05.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
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,...
1
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...
0
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...
1
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...
2
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...
6
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...
1
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...
7
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 ...
2
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.