473,326 Members | 2,168 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,326 software developers and data experts.

Combobox - Is this the right way?

I have a question regarding the combobox. I populated a Combobox on my
Windows form by databinding. In table I am binding contains a StaffID field
and a StaffName field.

When I ran a query to retrieve a field, I wanted to display the correct
value (StaffName) in the combobox. This is the code I came up with to do
that and was wondering if there is an automatic way to do this without
looping through the combobox
For index = 0 To cmbStaff.Items.Count - 1
cmbStaff.SelectedIndex = index
If rowContact("staff") = cmbStaff.SelectedValue Then
Exit For
End If
Next

Thanks,

Gary
Nov 21 '05 #1
3 939
Gary,

You documented it almost complete, however is "staff" the staffId or the
staffName and how do you get the row. Because when you know its position you
have the index. (And is it a datarow or a datarowview (the row from a
dataview)

Cor
Nov 21 '05 #2
cmbStaff.SelectedValue = rowContact("staff")
"Gary Paris" <te**@yada.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
I have a question regarding the combobox. I populated a Combobox on my
Windows form by databinding. In table I am binding contains a StaffID
field and a StaffName field.

When I ran a query to retrieve a field, I wanted to display the correct
value (StaffName) in the combobox. This is the code I came up with to do
that and was wondering if there is an automatic way to do this without
looping through the combobox
For index = 0 To cmbStaff.Items.Count - 1
cmbStaff.SelectedIndex = index
If rowContact("staff") = cmbStaff.SelectedValue Then
Exit For
End If
Next

Thanks,

Gary

Nov 21 '05 #3
Thanks for the input. I didn't know you could just set the SelectedValue.
I learned something new today.

Gary

"Stephany Young" <noone@localhost> wrote in message
news:eR**************@TK2MSFTNGP15.phx.gbl...
cmbStaff.SelectedValue = rowContact("staff")
"Gary Paris" <te**@yada.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
I have a question regarding the combobox. I populated a Combobox on my
Windows form by databinding. In table I am binding contains a StaffID
field and a StaffName field.

When I ran a query to retrieve a field, I wanted to display the correct
value (StaffName) in the combobox. This is the code I came up with to
do that and was wondering if there is an automatic way to do this without
looping through the combobox
For index = 0 To cmbStaff.Items.Count - 1
cmbStaff.SelectedIndex = index
If rowContact("staff") = cmbStaff.SelectedValue Then
Exit For
End If
Next

Thanks,

Gary


Nov 21 '05 #4

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

Similar topics

3
by: Pete | last post by:
I have a combobox which is used to select records, which is satisfactory at the moment. However, a second user is going to start using this database and there will be 1600 records. This makes...
7
by: Nicolae Fieraru | last post by:
Hi All, I am trying to change the rowsource of a combobox when I click on it. I played with many events, associated with the form and the combobox, but still haven't figured out what is the way...
0
by: Doug | last post by:
This is a repost of an item that I still cannot resolve. I have 3 combo boxes. The first leads to the second to the third. When I have selected a value in the second box, the third box shows...
4
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box...
2
by: VBTricks.de.vu Webmaster | last post by:
Hello, I'm still reimplementing the GUI of my app using the new toolstrips. My current problem is to autosize a combobox to the available with in the parent toolstrip. There are some buttons...
0
by: Hardik Shah | last post by:
Hi, I want to create menu , when my user right click from combo box's list item. I use Contextmenu property of combobox and assign menu for it, but it only effected when combobox's list item not...
4
by: JJGarcia | last post by:
Hi Everyone, I'll try to explain the process I'm following, I'm new to this so I'm triying the easy way first, probably the lasyest too! I created a new Project, drag in to it a SQLConnection,...
6
by: tbrown | last post by:
I have a combobox with items like this: {one,two,three}. The selected index is 0, so "one" appears in the combobox text. When the user drops down the list, and selects "two", for example, I...
8
by: =?Utf-8?B?RyBIdXN0aXM=?= | last post by:
This is the 2nd time posting so sorry for duplications. I am using VB.NT 2005 & a standard Combobox. I've been wracking my brain over this problem for a over a month & cannot seem to find a way to...
12
by: Gerhard | last post by:
This is bizarre... Im having problems with the combobox AfterUpdate event: Im running Access 2003. I created an unbound combobox with 3 columns on a form. The Row Source is from a table....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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...

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.