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

ComboBox keyboard recognition?

P: n/a
Could anyone help me with the following:

Is there a quick, or at least known way to
force a ComboBox, having DropDownStyle=
DropDownList, to recognize keyboard input
and perform Item selection based on that.

To be more specific: I have a list of 150 items
(all 7-digit numeric values) represented in
the combobox, and they are sorted. Instead
of scrolling to the specific item, I'd like to
be able to start typing on the keyboard and
have combobox recognize what I am typing,
and based on that, the selected value gets
changed. As I am progressing with the keyboard
input, the selection gets narrowed down.
Say I have to find number 1455601, and start
typing '1' on the keyboard, and first Item that starts
with '1' gets selected, then I type in '4', the second
digit, and then first item starting with '14' in the
combobox list gets selected, and I type in '5'
and selected item is first value starting with '145'
and so forth.

This behavior is very similar to Windows Explorer
(at least in WinXP) when there is a large number
of folders, and instead of scrolling up and down
the browser, typing in first few letters/numbers
of the folder, the sought folder gets selected.

Thanks in advance,

Strah

Nov 20 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Hello Strah
You can use something like it but it will only find one
character...

Private Sub ComboBox1_KeyDown(ByVal sender As Object,
ByVal e As System.Windows.Forms.KeyEventArgs) Handles
ComboBox1.KeyDown
Me.ComboBox1.FindString(e.KeyValue.ToString)
End Sub
Kind Regards
Jorge
-----Original Message-----
Could anyone help me with the following:

Is there a quick, or at least known way to
force a ComboBox, having DropDownStyle=
DropDownList, to recognize keyboard input
and perform Item selection based on that.

To be more specific: I have a list of 150 items
(all 7-digit numeric values) represented in
the combobox, and they are sorted. Instead
of scrolling to the specific item, I'd like to
be able to start typing on the keyboard and
have combobox recognize what I am typing,
and based on that, the selected value gets
changed. As I am progressing with the keyboard
input, the selection gets narrowed down.
Say I have to find number 1455601, and start
typing '1' on the keyboard, and first Item that starts
with '1' gets selected, then I type in '4', the second
digit, and then first item starting with '14' in the
combobox list gets selected, and I type in '5'
and selected item is first value starting with '145'
and so forth.

This behavior is very similar to Windows Explorer
(at least in WinXP) when there is a large number
of folders, and instead of scrolling up and down
the browser, typing in first few letters/numbers
of the folder, the sought folder gets selected.

Thanks in advance,

Strah

.

Nov 20 '05 #2

P: n/a
Well, the OP can already do that because when the Style is set to dropdown
list, the first character is searchable, but subsequent characters are not.

Regards - OHM
Jorge wrote:
Hello Strah
You can use something like it but it will only find one
character...

Private Sub ComboBox1_KeyDown(ByVal sender As Object,
ByVal e As System.Windows.Forms.KeyEventArgs) Handles
ComboBox1.KeyDown
Me.ComboBox1.FindString(e.KeyValue.ToString)
End Sub
Kind Regards
Jorge
-----Original Message-----
Could anyone help me with the following:

Is there a quick, or at least known way to
force a ComboBox, having DropDownStyle=
DropDownList, to recognize keyboard input
and perform Item selection based on that.

To be more specific: I have a list of 150 items
(all 7-digit numeric values) represented in
the combobox, and they are sorted. Instead
of scrolling to the specific item, I'd like to
be able to start typing on the keyboard and
have combobox recognize what I am typing,
and based on that, the selected value gets
changed. As I am progressing with the keyboard
input, the selection gets narrowed down.
Say I have to find number 1455601, and start
typing '1' on the keyboard, and first Item that starts
with '1' gets selected, then I type in '4', the second
digit, and then first item starting with '14' in the
combobox list gets selected, and I type in '5'
and selected item is first value starting with '145'
and so forth.

This behavior is very similar to Windows Explorer
(at least in WinXP) when there is a large number
of folders, and instead of scrolling up and down
the browser, typing in first few letters/numbers
of the folder, the sought folder gets selected.

Thanks in advance,

Strah

.


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com
Nov 20 '05 #3

P: n/a

Jorge,

thanks, but this is actually default behavior
of the ComboBox, so no code required.

I was going to use KeyDown event to
achieve what I need, but before starting
I wanted to double check if there was
something like that already available, just
to avoid re-inventing a wheel.

However, I was not aware of
ComboBox's FindString Method
which I will be using to build a
string of KeyValues provided by
the user.

Thanks again and Happy New Year,

Strah
--
Strah @ Langan

"Jorge" <an*******@discussions.microsoft.com> wrote in message
news:00****************************@phx.gbl...
Hello Strah
You can use something like it but it will only find one
character...

Private Sub ComboBox1_KeyDown(ByVal sender As Object,
ByVal e As System.Windows.Forms.KeyEventArgs) Handles
ComboBox1.KeyDown
Me.ComboBox1.FindString(e.KeyValue.ToString)
End Sub
Kind Regards
Jorge
-----Original Message-----
Could anyone help me with the following:

Is there a quick, or at least known way to
force a ComboBox, having DropDownStyle=
DropDownList, to recognize keyboard input
and perform Item selection based on that.

To be more specific: I have a list of 150 items
(all 7-digit numeric values) represented in
the combobox, and they are sorted. Instead
of scrolling to the specific item, I'd like to
be able to start typing on the keyboard and
have combobox recognize what I am typing,
and based on that, the selected value gets
changed. As I am progressing with the keyboard
input, the selection gets narrowed down.
Say I have to find number 1455601, and start
typing '1' on the keyboard, and first Item that starts
with '1' gets selected, then I type in '4', the second
digit, and then first item starting with '14' in the
combobox list gets selected, and I type in '5'
and selected item is first value starting with '145'
and so forth.

This behavior is very similar to Windows Explorer
(at least in WinXP) when there is a large number
of folders, and instead of scrolling up and down
the browser, typing in first few letters/numbers
of the folder, the sought folder gets selected.

Thanks in advance,

Strah

.

Nov 20 '05 #4

P: n/a
If you go to my site in about an hour, http://www.tiberiansun.us/Projects, I
have a control there that does a pattern match on what you typed in, so as
you type, things get eliminated. It's a new implementation of my old
AutoCombeX for VB6.

HTH
Sueffel
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.556 / Virus Database: 348 - Release Date: 12/26/2003
Nov 20 '05 #5

P: n/a
Hi Sueffel,

thanks for your help, I appreciate it a lot.
I am not sure I would change entire control
for something like that, I was just looking
for a possible property, or piece of code.
Now, that it seems that what I am looking
for is not that common, I will spend some
time to develop it myself.

Thanks,

--
Strah
"Sueffel" <so*****@somewhere.com> wrote in message
news:eU**************@TK2MSFTNGP11.phx.gbl...
If you go to my site in about an hour, http://www.tiberiansun.us/Projects, I have a control there that does a pattern match on what you typed in, so as
you type, things get eliminated. It's a new implementation of my old
AutoCombeX for VB6.

HTH
Sueffel
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.556 / Virus Database: 348 - Release Date: 12/26/2003

Nov 20 '05 #6

P: n/a
never mind, I've got it. thanks

--
Strah @ Langan

"Strahimir Antoljak" <st***@netzero.net> wrote in message
news:e3**************@TK2MSFTNGP09.phx.gbl...
Could anyone help me with the following:

Is there a quick, or at least known way to
force a ComboBox, having DropDownStyle=
DropDownList, to recognize keyboard input
and perform Item selection based on that.

To be more specific: I have a list of 150 items
(all 7-digit numeric values) represented in
the combobox, and they are sorted. Instead
of scrolling to the specific item, I'd like to
be able to start typing on the keyboard and
have combobox recognize what I am typing,
and based on that, the selected value gets
changed. As I am progressing with the keyboard
input, the selection gets narrowed down.
Say I have to find number 1455601, and start
typing '1' on the keyboard, and first Item that starts
with '1' gets selected, then I type in '4', the second
digit, and then first item starting with '14' in the
combobox list gets selected, and I type in '5'
and selected item is first value starting with '145'
and so forth.

This behavior is very similar to Windows Explorer
(at least in WinXP) when there is a large number
of folders, and instead of scrolling up and down
the browser, typing in first few letters/numbers
of the folder, the sought folder gets selected.

Thanks in advance,

Strah

Nov 20 '05 #7

P: n/a
OK, then let us have it too.

OHM
Strahimir Antoljak wrote:
never mind, I've got it. thanks
"Strahimir Antoljak" <st***@netzero.net> wrote in message
news:e3**************@TK2MSFTNGP09.phx.gbl...
Could anyone help me with the following:

Is there a quick, or at least known way to
force a ComboBox, having DropDownStyle=
DropDownList, to recognize keyboard input
and perform Item selection based on that.

To be more specific: I have a list of 150 items
(all 7-digit numeric values) represented in
the combobox, and they are sorted. Instead
of scrolling to the specific item, I'd like to
be able to start typing on the keyboard and
have combobox recognize what I am typing,
and based on that, the selected value gets
changed. As I am progressing with the keyboard
input, the selection gets narrowed down.
Say I have to find number 1455601, and start
typing '1' on the keyboard, and first Item that starts
with '1' gets selected, then I type in '4', the second
digit, and then first item starting with '14' in the
combobox list gets selected, and I type in '5'
and selected item is first value starting with '145'
and so forth.

This behavior is very similar to Windows Explorer
(at least in WinXP) when there is a large number
of folders, and instead of scrolling up and down
the browser, typing in first few letters/numbers
of the folder, the sought folder gets selected.

Thanks in advance,

Strah


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com
Nov 20 '05 #8

P: n/a

This solution will 'remember' your keys
typed sequence for 1200 milliseconds
(1.2 secs) and then it will start over (that
is similar to WinExplorer).

If you want the procedure to remember it
for some other timespan, change:
Now.AddMilliseconds(1200)
to
Now.AddMilliseconds(iOtherValue)

Thanks,

Strah

Private Sub ComboBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress

Static sFindString As String = ""
Static HoldForFewSecs As DateTime = "1/1/0001 12:00:00 AM"

If HoldForFewSecs = "1/1/0001 12:00:00 AM" Then HoldForFewSecs =
Now.AddMilliseconds(1200)

Dim index As Integer
If Now < HoldForFewSecs Then
sFindString &= e.KeyChar.ToString
index = Me.ComboBox1.FindString(sFindString)
ComboBox1.SelectedIndex = index
Else
sFindString = e.KeyChar.ToString
index = Me.ComboBox1.FindString(sFindString)
ComboBox1.SelectedIndex = index
HoldForFewSecs = "1/1/0001 12:00:00 AM"
End If

End Sub
--
Strah
"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in message
news:ud**************@TK2MSFTNGP10.phx.gbl...
OK, then let us have it too.

OHM
Strahimir Antoljak wrote:
never mind, I've got it. thanks
"Strahimir Antoljak" <st***@netzero.net> wrote in message
news:e3**************@TK2MSFTNGP09.phx.gbl...
Could anyone help me with the following:

Is there a quick, or at least known way to
force a ComboBox, having DropDownStyle=
DropDownList, to recognize keyboard input
and perform Item selection based on that.

To be more specific: I have a list of 150 items
(all 7-digit numeric values) represented in
the combobox, and they are sorted. Instead
of scrolling to the specific item, I'd like to
be able to start typing on the keyboard and
have combobox recognize what I am typing,
and based on that, the selected value gets
changed. As I am progressing with the keyboard
input, the selection gets narrowed down.
Say I have to find number 1455601, and start
typing '1' on the keyboard, and first Item that starts
with '1' gets selected, then I type in '4', the second
digit, and then first item starting with '14' in the
combobox list gets selected, and I type in '5'
and selected item is first value starting with '145'
and so forth.

This behavior is very similar to Windows Explorer
(at least in WinXP) when there is a large number
of folders, and instead of scrolling up and down
the browser, typing in first few letters/numbers
of the folder, the sought folder gets selected.

Thanks in advance,

Strah


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com

Nov 20 '05 #9

P: n/a
Thanx.

OHM

Strahimir Antoljak wrote:
This solution will 'remember' your keys
typed sequence for 1200 milliseconds
(1.2 secs) and then it will start over (that
is similar to WinExplorer).

If you want the procedure to remember it
for some other timespan, change:
Now.AddMilliseconds(1200)
to
Now.AddMilliseconds(iOtherValue)

Thanks,

Strah

Private Sub ComboBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress

Static sFindString As String = ""
Static HoldForFewSecs As DateTime = "1/1/0001 12:00:00 AM"

If HoldForFewSecs = "1/1/0001 12:00:00 AM" Then
HoldForFewSecs = Now.AddMilliseconds(1200)

Dim index As Integer
If Now < HoldForFewSecs Then
sFindString &= e.KeyChar.ToString
index = Me.ComboBox1.FindString(sFindString)
ComboBox1.SelectedIndex = index
Else
sFindString = e.KeyChar.ToString
index = Me.ComboBox1.FindString(sFindString)
ComboBox1.SelectedIndex = index
HoldForFewSecs = "1/1/0001 12:00:00 AM"
End If

End Sub

"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in
message news:ud**************@TK2MSFTNGP10.phx.gbl...
OK, then let us have it too.

OHM
Strahimir Antoljak wrote:
never mind, I've got it. thanks
"Strahimir Antoljak" <st***@netzero.net> wrote in message
news:e3**************@TK2MSFTNGP09.phx.gbl...
Could anyone help me with the following:

Is there a quick, or at least known way to
force a ComboBox, having DropDownStyle=
DropDownList, to recognize keyboard input
and perform Item selection based on that.

To be more specific: I have a list of 150 items
(all 7-digit numeric values) represented in
the combobox, and they are sorted. Instead
of scrolling to the specific item, I'd like to
be able to start typing on the keyboard and
have combobox recognize what I am typing,
and based on that, the selected value gets
changed. As I am progressing with the keyboard
input, the selection gets narrowed down.
Say I have to find number 1455601, and start
typing '1' on the keyboard, and first Item that starts
with '1' gets selected, then I type in '4', the second
digit, and then first item starting with '14' in the
combobox list gets selected, and I type in '5'
and selected item is first value starting with '145'
and so forth.

This behavior is very similar to Windows Explorer
(at least in WinXP) when there is a large number
of folders, and instead of scrolling up and down
the browser, typing in first few letters/numbers
of the folder, the sought folder gets selected.

Thanks in advance,

Strah


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com
Nov 20 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.