473,387 Members | 1,540 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,387 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 1908
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: 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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...

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.