By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,403 Members | 891 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,403 IT Pros & Developers. It's quick & easy.

Associate value with item in combobox

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.