Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

combobox autocomplete - DROPDOWNLIST

272 views
Skip to first unread message

Bernie Yaeger

unread,
Nov 14, 2004, 11:30:06 AM11/14/04
to
Everyone misses the point on this - what we need is a combobox autocomplete
that is a dropdownlist only. When in dropdown mode, you can enter text -
making that autocomplete is trivial. But when you look at combobox controls
from years ago, they would autocomplete in dropdownlist mode. And if you
look at intellisense, this is exactly what happens, so obviously the .net
framework can do it.

Any help would be much appreciated.

Bernie Yaeger


Ken Tucker [MVP]

unread,
Nov 14, 2004, 2:03:38 PM11/14/04
to
Hi,

http://www.thecodeproject.com/vb/net/autocomplete_combobox.asp

Ken
---------------------
"Bernie Yaeger" <ber...@cherwellinc.com> wrote in message
news:uxi90cm...@TK2MSFTNGP11.phx.gbl...

Bernie Yaeger

unread,
Nov 14, 2004, 6:04:17 PM11/14/04
to
Hi Ken,

You are easily one of the most knowledgeable and helpful people on this ng.
So it is that much more disappointing that you didn't read what I said -
THIS DOESN'T WORK WITH A DROPDOWNLIST COMBOBOX!

Bernie

"Ken Tucker [MVP]" <vb...@bellsouth.net> wrote in message
news:ukqEoyny...@TK2MSFTNGP12.phx.gbl...

Cor Ligthert

unread,
Nov 15, 2004, 2:30:49 AM11/15/04
to
Bernie,

> You are easily one of the most knowledgeable and helpful people on this
> ng. So it is that much more disappointing that you didn't read what I
> said - THIS DOESN'T WORK WITH A DROPDOWNLIST COMBOBOX!

If I understand you well, why than not make it your own by setting it in
combobox mode and doing a findstringexact when the user has selected an
item.

When it is not already in the combobox you can just ignore it, or even
ignore it with a message.

Maybe this helps, just a try?

Cor


Bernie Yaeger

unread,
Nov 15, 2004, 6:35:41 AM11/15/04
to
Hi Cor,

Findstringexact won't solve the problem.

Let's say the combobox contains

twist
soccer player
coral
comment
complete

What the user wants is to enter 'c' and get 'comment'; enter 'o' and stay on
'comment'; enter 'm' and stay on 'comment'; enter 'p' and go to 'complete'.

This is the way dropdownlist comboboxes used to work - for at least the last
10 years before .net.

Thanks for any help.

Bernie

"Cor Ligthert" <notmyfi...@planet.nl> wrote in message
news:uUxUFTuy...@TK2MSFTNGP15.phx.gbl...

Cor Ligthert

unread,
Nov 15, 2004, 6:45:01 AM11/15/04
to
Bernie,

That is what in my opinion that autocomplete combobox would do what Ken has
showed you.

The difference between a combobox and a listbox is that you may enter and
use text in a combobox that is not in the listcontrol.

Therefore I came with that idea about checking first with findstringexact

Cor

Bernie Yaeger

unread,
Nov 15, 2004, 7:03:38 AM11/15/04
to
Hi Cor,

There are lots of differences between a listbox and a combobox. But the
point is, in a combobox in dropdowlist mode, you cannot enter text - every
keystroke simply searches for the item that matches. By default, when in
dropdownlist mode, it simply finds the first item with the same initial
letter:

common
olive
call
complete

Entering a 'c' will find 'call', because it is first, alphabetically; then
entering an 'o' will find 'olive', etc. What I want - and what we had for
years - is for the user to enter 'c' and get call, but then enter 'o' and
get 'common', not 'olive'.

Bernie

"Cor Ligthert" <notmyfi...@planet.nl> wrote in message

news:eLTwHhwy...@TK2MSFTNGP09.phx.gbl...

Cor Ligthert

unread,
Nov 15, 2004, 7:16:18 AM11/15/04
to
Bernie,

I did write the wrong word, should have been combobox in dropdowlist mode
instead of listbox, however again, does that sample Ken showed you not do
that?

And than again, with the idea I added to that.

Cor

"Bernie Yaeger" <ber...@cherwellinc.com>

Aaron Smith

unread,
Nov 15, 2004, 8:17:34 AM11/15/04
to
Bernie,

I know exactly what you want and why you want it, and no the example he
gave is not it. However, if you subclass it, and then grab the keydown
event and build your own string while the control has focus, you could
probably do some sort of manual find on it to get the one they want. I
will need this as well once I get more of my current project completed...

Aaron


--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.

Bernie Yaeger

unread,
Nov 15, 2004, 9:46:50 AM11/15/04
to
Hi Aaron,

Tx for restoring my sanity!

Actually, I have already played around with the idea of using a global
string, exiting in the keyup event when tab, enter, arrows, etc and the
findstring with the global string. I then added a timer so that the global
string is cleared after a 2 second interval (so if you enter 'com' and wait
too long, 'p' with start again and find, say, 'paper'), because if you don't
clear the string the user can't make a second selection.

I may try to develop this into a custom control. If I do, I will email you
and let you know what I've done.

Bernie

"Aaron Smith" <thespi...@smithcentral.net> wrote in message
news:O%1md.28979$Qv5....@newssvr33.news.prodigy.com...

Aaron Smith

unread,
Nov 15, 2004, 10:32:12 AM11/15/04
to
That would be awesome!

Bernie Yaeger

unread,
Nov 15, 2004, 1:10:23 PM11/15/04
to
Hi Cor,

No; his suggestion only works for cropdown, not dropdownlist, comboboxes.
Your suggestion would not sequentially find, as findstringexact would not
begin the match until it was fully entered.

Bernie

"Cor Ligthert" <notmyfi...@planet.nl> wrote in message

news:eQ1umywy...@TK2MSFTNGP10.phx.gbl...

Cor Ligthert

unread,
Nov 15, 2004, 2:05:12 PM11/15/04
to
Bernie,

Now I understand where we misunderstand each other, I was talking after that
the complete filling was done, while you are talking doing it.

Cor

Bernie Yaeger

unread,
Nov 15, 2004, 3:09:21 PM11/15/04
to
Hi Cor,

Yes, exactly. I am testing using findstring against a global string. Let
know if you have any ideas that might help. Tx.

Bernie

"Cor Ligthert" <notmyfi...@planet.nl> wrote in message

news:e2LKGX0y...@TK2MSFTNGP11.phx.gbl...

Cor Ligthert

unread,
Nov 16, 2004, 12:43:11 PM11/16/04
to
Bernie,

To give me the idea, can you try if this is what you mean, you have to set
the combobox to the normal dropdown however set that dropdownliststyle to
true. I did not test it real deep, hower got the idea that it was working.

\\\
Private DropDownListStyle As Boolean
Private Sub combobox1_KeyUp(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) Handles ComboBox1.KeyUp
Dim cbo As ComboBox = DirectCast(sender, ComboBox)
Select Case e.KeyCode
Case Keys.Back, Keys.Left, Keys.Right, Keys.Up, Keys.Delete,
Keys.Down
Return
End Select
Dim ComboBoxText As String = cbo.Text
Dim FirstFound As Integer = cbo.FindString(ComboBoxText)
If FirstFound >= 0 Then
Dim FirstFoundItem As Object = cbo.Items(FirstFound)
Dim FirstFoundText As String = cbo.GetItemText(FirstFoundItem)
cbo.Text = FirstFoundText
cbo.SelectionStart = ComboBoxText.Length
cbo.SelectionLength = cbo.Text.Length
Else
If DropDownListStyle = True Then
cbo.Text = cbo.Text.Substring(0, cbo.Text.Length - 1)
cbo.SelectionStart = cbo.Text.Length
End If
End If
End Sub
///

I hope we reach the idea?

Cor


Bernie Yaeger

unread,
Nov 16, 2004, 2:05:41 PM11/16/04
to
Hi Cor,

There is only the dropdownstyle property, and it is not a boolean; rather it
sets to dropdown, dorpdownlist, etc. Is there a boolean property that I
can't see?

Tx

Bernie

"Cor Ligthert" <notmyfi...@planet.nl> wrote in message

news:OoLU9NAz...@TK2MSFTNGP12.phx.gbl...

Cor Ligthert

unread,
Nov 16, 2004, 2:30:00 PM11/16/04
to
Private DropDownListStyle As Boolean

In the top of my sample, when you use it as dropdownlist direct you cannot
enter keystrokes and it is so simple that making an inheritted combobox
seems too me a little bit overdone for that. I am thinking on another simple
improvement when it fits you.

Cor.

"Bernie Yaeger" <ber...@cherwellinc.com> schreef in bericht
news:eBjZF9Az...@TK2MSFTNGP11.phx.gbl...

Bernie Yaeger

unread,
Nov 16, 2004, 4:45:14 PM11/16/04
to
Hi Cor,

Yes, you are correct - your sample works fine! Thanks so much!

Bernie

"Cor Ligthert" <notmyfi...@planet.nl> wrote in message

news:O56SnJBz...@TK2MSFTNGP15.phx.gbl...

Sarah

unread,
Oct 6, 2005, 9:25:07 AM10/6/05
to
Hi,
I was wondering if you ever found a solution to this problem. I am facing something similar right now. I want the drop down to be read only and still have the autocomplete feature.

Appreciate your help.
Sarah

From http://developmentnow.com/g/38_2004_11_0_0_21657/combobox-autocomplete--DROPDOWNLIST.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com

Greg Burns

unread,
Oct 20, 2005, 11:19:28 AM10/20/05
to
I am using VB 2005. (is there a different group for these questions, since
we haven't reach the release date yet?)

I am playing with the new AutoCompleteMode property of the ComboBox.

When the combobox DropDownStyle is DropDown, autocomplete works as desired.
But it is not "limit-to-list" like old Access. Change the style to
DropDownList and now it is "limit-to-list", but no longer Autocompletes. :(

Anybody have a suggestion?

Greg

"Sarah" <nos...@developmentnow.com> wrote in message
news:4364e1e9-c5cc-45a4...@msnews.microsoft.com...

0 new messages