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

how can i get a query index from a combobox selection?

jen
i have select query that returns multiple records and populates a
combobox/pulldown.

once a selection from the pulldown is selected, i need to reference two
or three fileds from the previous query related to that selection.

as usual, i'm probably making this harder than it needs to be.

any help is newbiously appreciated.

thanks...

--
hail the forest daemon!

Oct 22 '06 #1
2 2499

jen wrote:
i have select query that returns multiple records and populates a
combobox/pulldown.

once a selection from the pulldown is selected, i need to reference two
or three fileds from the previous query related to that selection.
What you're looking for is what's unfortunately missing from the
ComboBox in the .NET framework: a Tag field on a combo box item that
allows you to connect it back to a business object or data row.

There are several ways to do this.

The simplest is to display the combo box items in the same order that
they are in the DataRowCollection, and use the combo box's
SelectedIndex to find the data row. So, if the user chooses an item
with index 5, you go and get the data row at index 5 (the sixth data
row) and that's the one that was chosen.

If you need a particular ordering for the combo box items, put a
DataView on top of the DataTable, and then populate the combo box from
the DataView.

Another way to do it is to put your data in objects and add them to the
combo box using its .Items.Add() method. You then set the ComboBox's
DisplayMember property to the name of the object property (as a string)
that the combo box should display to the user. So, for example, if your
data rows represent customers, you might say

comboBox1.DisplayMember = "Name";

to display the .Name property of the customer objects as the combo box
item text.

Now when the user selects an item in the combo box, you can use
SelectedItem to get the object they selected.

Oct 23 '06 #2
jen

Bruce Wood wrote:
jen wrote:
i have select query that returns multiple records and populates a
combobox/pulldown.

once a selection from the pulldown is selected, i need to reference two
or three fileds from the previous query related to that selection.

What you're looking for is what's unfortunately missing from the
ComboBox in the .NET framework: a Tag field on a combo box item that
allows you to connect it back to a business object or data row.

There are several ways to do this.

The simplest is to display the combo box items in the same order that
they are in the DataRowCollection, and use the combo box's
SelectedIndex to find the data row. So, if the user chooses an item
with index 5, you go and get the data row at index 5 (the sixth data
row) and that's the one that was chosen.

If you need a particular ordering for the combo box items, put a
DataView on top of the DataTable, and then populate the combo box from
the DataView.

Another way to do it is to put your data in objects and add them to the
combo box using its .Items.Add() method. You then set the ComboBox's
DisplayMember property to the name of the object property (as a string)
that the combo box should display to the user. So, for example, if your
data rows represent customers, you might say

comboBox1.DisplayMember = "Name";

to display the .Name property of the customer objects as the combo box
item text.

Now when the user selects an item in the combo box, you can use
SelectedItem to get the object they selected.
hey bruce thanks for the reply. sorry i didn't get back sooner. i
figured out a way to index it the way i wanted. thanks again!

--
jen

Nov 6 '06 #3

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

Similar topics

3
by: Wayne Wengert | last post by:
I am trying to populate a combobox with a lisy of items. I want the 1st item to be "Make a Selection" and the following items will be names from a table in my DB (See code below). When I run the...
3
by: Paul Mateer | last post by:
Hi, I have been running some queries against a table in a my database and have noted an odd (at least it seems odd to me) performance issue. The table has approximately 5 million rows and...
1
by: Steve | last post by:
I have a continuous form with several unbound comboboxes in the form header. The comboboxes are used to provide criteria for the SQL of the form. The code behind the form looks like: Public Sub...
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...
1
by: CCC | last post by:
Our company have used Excel to filter out documents base on date, from_company, type_of_document, country to generate a list of where the documents physical location is. The number of records have...
3
by: Ray Holtz | last post by:
Access 2003 (2000 file format) question: When I run a form, it opens with only a combo box and a button to execute a query based on the criteria tha is selected in the combobox. Then I need...
3
by: Magnus | last post by:
Im using a set combobox (ComboBox1) to provide a selection of records from a database table. I have a typed dataset (DataSet1) that contains the typed datatable (DataTable1) that the combobox is...
18
by: WU10 | last post by:
Built a form based on a select query with a combo box (3 choices) in the form header which will supply a value to the query. In the query's criteria I added the following expression - !! and...
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...
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...
0
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,...
0
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...
0
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,...
0
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...
0
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...
0
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...

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.