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

Silly ComboBox Question

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
10 1903
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
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
Cor
Hi EricJ,

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

Cor
Jul 21 '05 #4
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
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
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
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
Cor
Did you try it?
Jul 21 '05 #9
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Georges Heinesch | last post by:
An easy ComboBox question. ;) I would like to create a ComboBox, which permits to cycle through 3 subforms. These 3 subforms are entered in the ComboBox as Value List. The subforms should only...
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...
4
by: David Sworder | last post by:
Hi, I have a ComboBox that contains 1,400 sorted items . Here's the list: abba apple ... cabba caccaa capple
3
by: kalantre | last post by:
Hello, I have a Windows form that displays some data from a database. The only two controls worth talking about are one ComboBox and one Rich Text Control. When I show the dialog, the focus...
4
by: Beeeeeeeeeeeeves | last post by:
I have an ownerdrawn combo box which I am drawing with an image and some text, this is all working beautifully apart from the difference in the Brush I have to draw the background and the text with...
0
by: Hiroyuki Tanaka | last post by:
Hi All, I am trying to develop an application for a touch screen using buttons for the numeric pad with Completion ComboBoxes. At the moment I am having a problem sending the button presses to...
2
by: pei_world | last post by:
I want to implement a key hit with enter to dropdown a combobox that is in the datagrid. in this case I need to override its original behaviours. I found some codes from the web. Does anyone know...
10
by: Mr. B | last post by:
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...
6
by: Sakharam Phapale | last post by:
Hi All, How to fill one ComboBox from other ComboBox control? 1) Only setting the reference does the trick but doesn't show items in control. If you see in immediate window, it shows...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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...

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.