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

Silly ComboBox Question

P: n/a
I've been seeking the solution to this. But can't figure it out (sounds
simple enough).

When you Populat a ComboBox, you can select the initial displayed items on
startup simply by setting the TEXT to a valide item in the Combobox.

What I want to do is to select the initial listed item to an item based upon a
varrying veriable.

For example, the combobox is populated with a list of Users.

I then have a command line argument with a user name in it.

Application starts up and the Combobox shows their name.

What's really happening is that I do something like the above. But I'm
opening up an MS Access DB (via ADO). But instead of the User name, I have
only a User code number (ie: BRU001 for Bruce, DAV001 for David, etc.)

My combobox lists the User Code. I've a Text Box that displays the correct
user name based upon the user code (cause they are on the same data base row
and are in synch).

But I can't figure out how to select the initial view of the Combobox (always
get the first user code displayed).

Any help will be appreciated.

Regards,

Bruce
Jul 21 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
Cor
Hi Mr B.

I am always a little scared with answering your questions, because I am not
sure if you use the windowforms Combobox or the webform Listdropbox.

But with windowforms Combobox you can do
\\\
combobox.selectedindex = combobox.findstring("name")
///
Cor
Jul 21 '05 #2

P: n/a
personally i would use the combobox.findstringexact(string) if you use the
normal findstring you get the first item matching conditions (could be
dangerous i think)

eric

"Cor" <no*@non.com> wrote in message
news:u4**************@TK2MSFTNGP09.phx.gbl...
Hi Mr B.

I am always a little scared with answering your questions, because I am not sure if you use the windowforms Combobox or the webform Listdropbox.

But with windowforms Combobox you can do
\\\
combobox.selectedindex = combobox.findstring("name")
///
Cor

Jul 21 '05 #3

P: n/a
Cor
Hi EricJ,

I think you are in most cases right, thank you for making me attent on this

Cor
Jul 21 '05 #4

P: n/a
no problem :)
im far from knowing as much as you guys but i try to help if i can

"Cor" <no*@non.com> wrote in message
news:3f***********************@reader20.wxs.nl...
Hi EricJ,

I think you are in most cases right, thank you for making me attent on this
Cor

Jul 21 '05 #5

P: n/a
With Deft Fingers, "EricJ" <ericRéMo**@ThiSomnipack.be> wrote:
personally i would use the combobox.findstringexact(string) if you use the
normal findstring you get the first item matching conditions (could be
dangerous i think)


Mucho appreciated. I think I was close... but got too frustrated in the so
many failures (:

Bruce
Jul 21 '05 #6

P: n/a
With Deft Fingers, "Cor" <no*@non.com> wrote:
I think you are in most cases right, thank you for making me attent on this


Both of you scare me (:

Thanks for your reply.

Bruce
Jul 21 '05 #7

P: n/a
With Deft Fingers, "EricJ" <ericRéMo**@ThiSomnipack.be> wrote:
personally i would use the combobox.findstringexact(string) if you use the
normal findstring you get the first item matching conditions (could be
dangerous i think)

But with windowforms Combobox you can do
\\\
combobox.selectedindex = combobox.findstring("name")
///


Hmmmm.... I don' think this works.

Maybe I need to re-explain my question...

I've a VB.net Windowforms Combobox that gets populated with User ID
information (such as BEV001, FEU001, MAT002, etc) from a data base query on
application startup.

What I want to do (in form load) is to find the User ID index number so that I
can set the Displayed ID on startup.

Graphical display of requirement:

ComboBox1 filled with the following from a data base on startup:
BEV001 (position 0)
DAN001 (position 1)
FEU001 (position 2)
MAT001 (position 3)
TUS001 (position 4)

My user (FEU001) starts up the application. In the app shortcut, I've a
commandline argument where they have their User ID (FEU001).

The app starts... the data base fills the Combobox... now I want to find
FEU001 in the Combobox and set the 'display' for the Combobox to Position 2
(FEU001 position).

Thoughts?

Regards,

Bruce
Jul 21 '05 #8

P: n/a
Cor
Did you try it?
Jul 21 '05 #9

P: n/a
With Deft Fingers, "Cor" <no*@non.com> wrote:
Did you try it?


Yes (unless I did it wrong). But what I got was the current Index of 0.

My Search is a String:

Dim strUserID As String ' User Name Filter

In Form Load I have (I'm using Test.Text to test the Results):

strUserID = UCase("feu001")

cmbUserName.SelectedIndex = cmbUserName.FindString(strUserID)
Test.Text = cmbUserName.SelectedIndex

Regards,

Bruce
Jul 21 '05 #10

P: n/a
With Deft Fingers, "Cor" <no*@non.com> wrote:
Did you try it?


Well I found out that your Code DOES work. What I've got is a situation in
which the ComboBox "SelectedIndexChanged" event changes my result on FormLoad
:(

I've run across this before... IF I disable the SelectedIndexChanged stuff...
no problems. But somehow, in the startup, the SelectedIndexChanged falls back
to Index 0.

Bruce
Jul 21 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.