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

How to query the key and value pair in ComboBox

I am using the following code as an example. Once the user selects an item
from the combobox (e.g., "Martin"), how can I access the value of that item
(e.g., "1")?

Thank you,

DD

Dim dtAdjuster as new DataTable
dtAdjuster.Columns.add("Names")
dtAdjuster.Columns.add("Keys")

dtAdjuster.loaddatarow(new object() {"Martin", "1"},true)
dtAdjuster.loaddatarow(new object() {"Cor","2"},true)

'This can all in probably hundred other ways, this is the way I do it.

Combobox1.datasource = dt
Combobox1.displaymember = "Names"
Combobox1.Valuemember = "Keys"
Feb 22 '06 #1
2 2883
> I am using the following code as an example. Once the user selects an
item from the combobox (e.g., "Martin"), how can I access the value of
that item (e.g., "1")?

Dim dtAdjuster as new DataTable
dtAdjuster.Columns.add("Names")
dtAdjuster.Columns.add("Keys")
dtAdjuster.loaddatarow(new object() {"Martin", "1"},true)
dtAdjuster.loaddatarow(new object() {"Cor","2"},true)

'This can all in probably hundred other ways, this is the way I do it.

Combobox1.datasource = dt
Combobox1.displaymember = "Names"
Combobox1.Valuemember = "Keys"


Combobox1.SelectedValue.ToString
Feb 22 '06 #2
I tried that, it is returning "System.Data.DataRowView" as the value of the
item. What is wrong? Any idea?

"Jim Wooley" wrote:
I am using the following code as an example. Once the user selects an
item from the combobox (e.g., "Martin"), how can I access the value of
that item (e.g., "1")?

Dim dtAdjuster as new DataTable
dtAdjuster.Columns.add("Names")
dtAdjuster.Columns.add("Keys")
dtAdjuster.loaddatarow(new object() {"Martin", "1"},true)
dtAdjuster.loaddatarow(new object() {"Cor","2"},true)

'This can all in probably hundred other ways, this is the way I do it.

Combobox1.datasource = dt
Combobox1.displaymember = "Names"
Combobox1.Valuemember = "Keys"


Combobox1.SelectedValue.ToString

Feb 22 '06 #3

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

Similar topics

6
by: JT | last post by:
Hello all, I've been using sql and mysql in particular for several years now, but I'm having some trouble coming up with a query that will pull the data that I need from a mysql table without using...
3
by: Dr. Oz | last post by:
Hi, I am trying to read in a query string from one page and build a link to another page based on the query string. Here's the code I am using to read in the query string: <script...
3
by: Steve | last post by:
Form FrmRestock's recordsource is QryFrmRestock. The TransactionDate field's criteria is set ats: Forms!FrmRestock!LastXDays. LastXDays on the form is a combobox where the selections are 30, 60...
2
by: Ellen Manning | last post by:
Using A2K. In my table I have the field "Grant" which can have a value or be null. I have a query that counts the number of records and has a Where clause on the Grant field. The query won't...
1
by: Giulio | last post by:
Hello, I have a continuous form with a combo box inside. From the combo box I can pick some values which, by the "after-update" event, change some other combo box values determined by a query....
2
by: Fred | last post by:
Hi, I am having a problem setting a combobox value in code on form load using comboBox.SelectedValue method. The code below when debugging show the combobox equal to an undefined value. The...
7
by: RSH | last post by:
I need to use a form element to display a list of users. I would like to store their ID "behind the scenes" so when the user selects a name the Event passes their ID. I can't find anything...
1
by: The.Daryl.Lu | last post by:
Hi, two parts to my problem if someone can help address either one or both: 1. I want to SELECT everything in the table if it matches the criteria when the query button is pressed (this is just...
5
by: jmDesktop | last post by:
I know this should be straight forward, but I have not gotten it yet. I have a combobox and a textbox. I want to display what is selected in the combobox in the textbox. I have: ...
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
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.