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

AutoComplete Entry in ComboBox?

Here's the situation...

You've a combobox with Items already added. Say they look like this (or even
lines of text):

10-00-232
10-00-256
10-01-006
10-01-213
10-02-200
10-03-045

How does one code the Combobox so that when you manually start to enter the
Item in the Combobox line, it AutoCompletes the input??

Many thanks!

Bruce
Jul 21 '05 #1
13 2728
http://www.csharphelp.com/archives3/archive502.html
http://www-level3.experts-exchange.c..._20677158.html

HTH,

Bill
"Mr. B" <Us**@NoWhere.Com> wrote in message
news:7v********************************@4ax.com...
Here's the situation...

You've a combobox with Items already added. Say they look like this (or even lines of text):

10-00-232
10-00-256
10-01-006
10-01-213
10-02-200
10-03-045

How does one code the Combobox so that when you manually start to enter the Item in the Combobox line, it AutoCompletes the input??

Many thanks!

Bruce

Jul 21 '05 #2
With Deft Fingers, "William Ryan" <do********@nospam.comcast.net> wrote:
http://www.csharphelp.com/archives3/archive502.html
http://www-level3.experts-exchange.c..._20677158.html


Awwwww... William... you C# guy... sadly to say I'm only a VB.net kinda person
(:

But Thanks any ways...

Bruce
Jul 21 '05 #3
Hi Bruce,
that shouldn't too much of a problem. First of all it's not very hard to
port C# to VB.net. At least if you have a basic understanding of the C/C#
syntax.
On the other just download the zip from C# help (1st link William provided).
If haven't verified but it states the compiled dll is there, too. This
should be useable without problems from any .NET language.

Matti

"Mr. B" <Us**@NoWhere.Com> schrieb im Newsbeitrag
news:i4********************************@4ax.com...
With Deft Fingers, "William Ryan" <do********@nospam.comcast.net> wrote:
http://www.csharphelp.com/archives3/archive502.html
http://www-level3.experts-exchange.c...g_Languages/C_

Sharp/Q_20677158.html
Awwwww... William... you C# guy... sadly to say I'm only a VB.net kinda person (:

But Thanks any ways...

Bruce

Jul 21 '05 #4
With Deft Fingers, "Matthias Klöpper" <mk*******@ba-com.net> wrote:
that shouldn't too much of a problem. First of all it's not very hard to
port C# to VB.net. At least if you have a basic understanding of the C/C#
Okay... don't know anything about C# though (:
If haven't verified but it states the compiled dll is there, too. This
should be useable without problems from any .NET language.


A DLL file? Hmmm... I'll see about that.

Thanks!

Bruce
Jul 21 '05 #5
this dous w you need (deleted some things but normally nothing essential)

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

Dim Combo As ComboBox = CType(sender, ComboBox)

If Asc(e.KeyChar) = Keys.Escape Then

Combo.SelectedIndex = -1

Combo.Text = ""

Controlkey = True

ElseIf Char.IsControl(e.KeyChar) Then

Controlkey = True

Else

Controlkey = False

End If

End Sub

Private Sub cboProduct_TextChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cboProduct.TextChanged

Dim Combo As ComboBox = CType(sender, ComboBox)

If Combo.Text <> "" And Not Controlkey Then

Dim MatchText As String = Combo.Text

Dim Match As Integer = Combo.FindString(MatchText, -1)

'als gevonden invoegen

If Match <> -1 Then

Combo.SelectedIndex = Match

'de toegevoegde tekst selecteren zodat de gebruiker verder kan typen

Combo.SelectionStart = MatchText.Length

Combo.SelectionLength = Combo.Text.Length - Combo.SelectionStart

End If

End Sub

Private Sub cboProduct_Leave(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cboProduct.Leave

Dim Combo As ComboBox = CType(sender, ComboBox)

If Combo.Text <> "" Then

'zoeken naar zelfde

Dim MatchText As String = Combo.Text

Dim Match As Integer = Combo.FindStringExact(MatchText)

If Match <> -1 Then

Combo.SelectedIndex = Match

End If

Else

stbp2.Text = "Not in list"

Combo.Focus()

Combo.SelectAll()

End If

End If

End Sub

"Mr. B" <Us**@NoWhere.Com> wrote in message
news:7v********************************@4ax.com...
Here's the situation...

You've a combobox with Items already added. Say they look like this (or even lines of text):

10-00-232
10-00-256
10-01-006
10-01-213
10-02-200
10-03-045

How does one code the Combobox so that when you manually start to enter the Item in the Combobox line, it AutoCompletes the input??

Many thanks!

Bruce

Jul 21 '05 #6
i'll do you 1 better... here is a link to a c# -- VB converter.
I grabbed this from someone on this news forum (I forget from whom exactly)

http://kryptonite.headsense.com/CSToVBWeb/

maybe kryptonite...
"Mr. B" <Us**@NoWhere.Com> wrote in message
news:8e********************************@4ax.com...
With Deft Fingers, "Matthias Klöpper" <mk*******@ba-com.net> wrote:
that shouldn't too much of a problem. First of all it's not very hard to
port C# to VB.net. At least if you have a basic understanding of the C/C#


Okay... don't know anything about C# though (:
If haven't verified but it states the compiled dll is there, too. This
should be useable without problems from any .NET language.


A DLL file? Hmmm... I'll see about that.

Thanks!

Bruce

Jul 21 '05 #7
With Deft Fingers, ":\\\\derian" <de****@someplace.com> wrote:
i'll do you 1 better... here is a link to a c# -- VB converter.
I grabbed this from someone on this news forum (I forget from whom exactly)


Interesting... I'll check it out.

Thanks!

Bruce
Jul 21 '05 #8
With Deft Fingers, "EricJ" <ericRéMo**@ThiSomnipack.be> wrote:
this dous w you need (deleted some things but normally nothing essential)


Thanks. I'll try to see if I can get it to work.

Regards,

Bruce
Jul 21 '05 #9
Hi Eric
This is a useful sub that I have also been looking for. Thanks!
Just in case some completely newbies look in this code I have corrected two
things:
You need to declare a controlKey boolean variable in the top of your form
code:
Public Class Form1

Inherits System.Windows.Forms.Form

Dim Controlkey As Boolean

' And I believe one of your If-Endif was misplaced

Private Sub cboProduct_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles cboProduct.KeyPress
Dim Combo As ComboBox = CType(sender, ComboBox)

If Asc(e.KeyChar) = Keys.Escape Then

Combo.SelectedIndex = -1

Combo.Text = ""

Controlkey = True

ElseIf Char.IsControl(e.KeyChar) Then

Controlkey = True

Else

Controlkey = False

End If

End Sub

Private Sub cboProduct_TextChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cboProduct.TextChanged

Dim Combo As ComboBox = CType(sender, ComboBox)

If Combo.Text <> "" And Not Controlkey Then

Dim MatchText As String = Combo.Text

Dim Match As Integer = Combo.FindString(MatchText, -1)

If Match <> -1 Then

Combo.SelectedIndex = Match

Combo.SelectionStart = MatchText.Length

Combo.SelectionLength = Combo.Text.Length - Combo.SelectionStart

End If

End If

End Sub

Private Sub cboProduct_Leave(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cboProduct.Leave

Dim Combo As ComboBox = CType(sender, ComboBox)

If Combo.Text <> "" Then

Dim MatchText As String = Combo.Text

Dim Match As Integer = Combo.FindStringExact(MatchText)

If Match <> -1 Then

Combo.SelectedIndex = Match

Else

Label1.Text = "Not in list"

Combo.Focus()

Combo.SelectAll()

End If

End If

End Sub
This code works in my projects anyway.

Best regards

Jan
"EricJ" <ericRéMo**@ThiSomnipack.be> skrev i en meddelelse
news:3f*********************@reader3.news.skynet.b e...
this dous w you need (deleted some things but normally nothing essential)

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

Dim Combo As ComboBox = CType(sender, ComboBox)

If Asc(e.KeyChar) = Keys.Escape Then

Combo.SelectedIndex = -1

Combo.Text = ""

Controlkey = True

ElseIf Char.IsControl(e.KeyChar) Then

Controlkey = True

Else

Controlkey = False

End If

End Sub

Private Sub cboProduct_TextChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cboProduct.TextChanged

Dim Combo As ComboBox = CType(sender, ComboBox)

If Combo.Text <> "" And Not Controlkey Then

Dim MatchText As String = Combo.Text

Dim Match As Integer = Combo.FindString(MatchText, -1)

'als gevonden invoegen

If Match <> -1 Then

Combo.SelectedIndex = Match

'de toegevoegde tekst selecteren zodat de gebruiker verder kan typen

Combo.SelectionStart = MatchText.Length

Combo.SelectionLength = Combo.Text.Length - Combo.SelectionStart

End If

End Sub

Private Sub cboProduct_Leave(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cboProduct.Leave

Dim Combo As ComboBox = CType(sender, ComboBox)

If Combo.Text <> "" Then

'zoeken naar zelfde

Dim MatchText As String = Combo.Text

Dim Match As Integer = Combo.FindStringExact(MatchText)

If Match <> -1 Then

Combo.SelectedIndex = Match

End If

Else

stbp2.Text = "Not in list"

Combo.Focus()

Combo.SelectAll()

End If

End If

End Sub

"Mr. B" <Us**@NoWhere.Com> wrote in message
news:7v********************************@4ax.com...
Here's the situation...

You've a combobox with Items already added. Say they look like this (or

even
lines of text):

10-00-232
10-00-256
10-01-006
10-01-213
10-02-200
10-03-045

How does one code the Combobox so that when you manually start to enter

the
Item in the Combobox line, it AutoCompletes the input??

Many thanks!

Bruce


Jul 21 '05 #10
correct i forgot the Private Controlkey as boolean and i deleted an end if
to much :)

btw if you are interested in only auto filling when there is only 1 inctance
of the text you are typing i have that 2 (boss dousn't like the possibility
of fast inputters making mistakes)

"Jan Nielsen" <Re**************@tiscali.dk> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
Hi Eric
This is a useful sub that I have also been looking for. Thanks!
Just in case some completely newbies look in this code I have corrected two things:
You need to declare a controlKey boolean variable in the top of your form
code:
Public Class Form1

Inherits System.Windows.Forms.Form

Dim Controlkey As Boolean

' And I believe one of your If-Endif was misplaced

Private Sub cboProduct_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles cboProduct.KeyPress
Dim Combo As ComboBox = CType(sender, ComboBox)

If Asc(e.KeyChar) = Keys.Escape Then

Combo.SelectedIndex = -1

Combo.Text = ""

Controlkey = True

ElseIf Char.IsControl(e.KeyChar) Then

Controlkey = True

Else

Controlkey = False

End If

End Sub

Private Sub cboProduct_TextChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cboProduct.TextChanged

Dim Combo As ComboBox = CType(sender, ComboBox)

If Combo.Text <> "" And Not Controlkey Then

Dim MatchText As String = Combo.Text

Dim Match As Integer = Combo.FindString(MatchText, -1)

If Match <> -1 Then

Combo.SelectedIndex = Match

Combo.SelectionStart = MatchText.Length

Combo.SelectionLength = Combo.Text.Length - Combo.SelectionStart

End If

End If

End Sub

Private Sub cboProduct_Leave(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cboProduct.Leave

Dim Combo As ComboBox = CType(sender, ComboBox)

If Combo.Text <> "" Then

Dim MatchText As String = Combo.Text

Dim Match As Integer = Combo.FindStringExact(MatchText)

If Match <> -1 Then

Combo.SelectedIndex = Match

Else

Label1.Text = "Not in list"

Combo.Focus()

Combo.SelectAll()

End If

End If

End Sub
This code works in my projects anyway.

Best regards

Jan

Jul 21 '05 #11
Hi Eric
Actually I have a little problem with your code.
I have a sub on the SelectedIndexChanged for my combo that creates an email.
And your code calls this.

So if I have ie IPC and IPA in the combo item list, when I type I-P it
selects the first (IPA or IPC depending on my sort order) and trigger my
SelectedIndexChanged sub and creates an email for the first item matching
I-P. It does not give me a chance to decide whether I actually wanted
another item starting with IP.

Jan

"EricJ" <ericRéMo**@ThiSomnipack.be> skrev i en meddelelse
news:3f**********************@reader2.news.skynet. be...
correct i forgot the Private Controlkey as boolean and i deleted an end if
to much :)

btw if you are interested in only auto filling when there is only 1 inctance of the text you are typing i have that 2 (boss dousn't like the possibility of fast inputters making mistakes)

"Jan Nielsen" <Re**************@tiscali.dk> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
Hi Eric
This is a useful sub that I have also been looking for. Thanks!
Just in case some completely newbies look in this code I have corrected

two
things:
You need to declare a controlKey boolean variable in the top of your form code:
Public Class Form1

Inherits System.Windows.Forms.Form

Dim Controlkey As Boolean

' And I believe one of your If-Endif was misplaced

Private Sub cboProduct_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles cboProduct.KeyPress
Dim Combo As ComboBox = CType(sender, ComboBox)

If Asc(e.KeyChar) = Keys.Escape Then

Combo.SelectedIndex = -1

Combo.Text = ""

Controlkey = True

ElseIf Char.IsControl(e.KeyChar) Then

Controlkey = True

Else

Controlkey = False

End If

End Sub

Private Sub cboProduct_TextChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cboProduct.TextChanged

Dim Combo As ComboBox = CType(sender, ComboBox)

If Combo.Text <> "" And Not Controlkey Then

Dim MatchText As String = Combo.Text

Dim Match As Integer = Combo.FindString(MatchText, -1)

If Match <> -1 Then

Combo.SelectedIndex = Match

Combo.SelectionStart = MatchText.Length

Combo.SelectionLength = Combo.Text.Length - Combo.SelectionStart

End If

End If

End Sub

Private Sub cboProduct_Leave(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cboProduct.Leave

Dim Combo As ComboBox = CType(sender, ComboBox)

If Combo.Text <> "" Then

Dim MatchText As String = Combo.Text

Dim Match As Integer = Combo.FindStringExact(MatchText)

If Match <> -1 Then

Combo.SelectedIndex = Match

Else

Label1.Text = "Not in list"

Combo.Focus()

Combo.SelectAll()

End If

End If

End Sub
This code works in my projects anyway.

Best regards

Jan


Jul 21 '05 #12

that is becouse you change the selected index when the text changes, have a
look at the following
here it wil not select anithing until there is only 1 possibility left if
there are more possiblilities it wil convert the text to uppercase so the
user knows he's not typing anithing wrong

i didn't test this against the selected index changed but i think you can
work with this

i did wonder wouldn't it be better to generate your e-mail in the leave
event? you can check if the value has changed there.
Private Sub cboProduct_TextChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cboProduct.TextChanged

Dim Combo As ComboBox = CType(sender, ComboBox)

If Combo.Text <> "" And Not Controlkey Then

'zoeken naar zelfde

Dim MatchText As String = Combo.Text

Dim Match As Integer = Combo.FindString(MatchText, -1)

'als gevonden invoegen

If Match <> -1 Then

Dim y As Integer = 1

Dim g As Integer

g = Combo.FindString(MatchText, Match + 1)

If g <> Match Then

y += 1

End If

If y = 1 Then

Combo.SelectedIndex = Match

'de toegevoegde tekst selecteren zodat de gebruiker verder kan typen

Combo.SelectionStart = MatchText.Length

Combo.SelectionLength = Combo.Text.Length - Combo.SelectionStart

Else

Combo.Text = MatchText.ToUpper

Combo.SelectionStart = MatchText.Length

'Combo.SelectionLength = Combo.Text.Length - Combo.SelectionStart

End If

End If

End If

End Sub

"Jan Nielsen" <Re**************@tiscali.dk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi Eric
Actually I have a little problem with your code.
I have a sub on the SelectedIndexChanged for my combo that creates an email. And your code calls this.

So if I have ie IPC and IPA in the combo item list, when I type I-P it
selects the first (IPA or IPC depending on my sort order) and trigger my
SelectedIndexChanged sub and creates an email for the first item matching
I-P. It does not give me a chance to decide whether I actually wanted
another item starting with IP.

Jan

Jul 21 '05 #13
Hi Eric
Thanks for answering
I also send an email in the Leave event.
But I would _also_ like the user to be able to select a group from the list
and see the email generated without having to press Enter or move focus from
the combo.

I shall look into your example

Thanks

Jan

"EricJ" <ericRéMo**@ThiSomnipack.be> skrev i en meddelelse
news:3f**********************@reader2.news.skynet. be...

that is becouse you change the selected index when the text changes, have a look at the following
here it wil not select anithing until there is only 1 possibility left if
there are more possiblilities it wil convert the text to uppercase so the
user knows he's not typing anithing wrong

i didn't test this against the selected index changed but i think you can
work with this

i did wonder wouldn't it be better to generate your e-mail in the leave
event? you can check if the value has changed there.
Private Sub cboProduct_TextChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cboProduct.TextChanged

Dim Combo As ComboBox = CType(sender, ComboBox)

If Combo.Text <> "" And Not Controlkey Then

'zoeken naar zelfde

Dim MatchText As String = Combo.Text

Dim Match As Integer = Combo.FindString(MatchText, -1)

'als gevonden invoegen

If Match <> -1 Then

Dim y As Integer = 1

Dim g As Integer

g = Combo.FindString(MatchText, Match + 1)

If g <> Match Then

y += 1

End If

If y = 1 Then

Combo.SelectedIndex = Match

'de toegevoegde tekst selecteren zodat de gebruiker verder kan typen

Combo.SelectionStart = MatchText.Length

Combo.SelectionLength = Combo.Text.Length - Combo.SelectionStart

Else

Combo.Text = MatchText.ToUpper

Combo.SelectionStart = MatchText.Length

'Combo.SelectionLength = Combo.Text.Length - Combo.SelectionStart

End If

End If

End If

End Sub

"Jan Nielsen" <Re**************@tiscali.dk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi Eric
Actually I have a little problem with your code.
I have a sub on the SelectedIndexChanged for my combo that creates an

email.
And your code calls this.

So if I have ie IPC and IPA in the combo item list, when I type I-P it
selects the first (IPA or IPC depending on my sort order) and trigger my
SelectedIndexChanged sub and creates an email for the first item matching I-P. It does not give me a chance to decide whether I actually wanted
another item starting with IP.

Jan


Jul 21 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: VM | last post by:
How can I implement the autocomplete functionality in a Windows comboBox? Thanks.
3
by: RajW | last post by:
Is it possible to have an auto complete ComboBox in ASP.NET? I would like to create a ComboBox that functions similarly to the way that IE will try to autocomplete a URL as you type it in. ...
19
by: Mr. B | last post by:
Here's the situation... You've a combobox with Items already added. Say they look like this (or even lines of text): 10-00-232 10-00-256 10-01-006 10-01-213 10-02-200
19
by: Bernie Yaeger | last post by:
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...
0
by: peter78 | last post by:
I wanted to implement an autocomplete feature on the combobox where you would type in partial text and it would try to match it for you. It doesn't exist in .Net yet, but I'm guessing it will in...
0
by: Matewis | last post by:
Once you’ve populated a ComboBox with items and your AutoComplete – SuggestAppend properties are enabled the following is a problem. When you select an item where a duplicate item exists and...
5
by: Andrus | last post by:
I'm creating a database Winforms application using VCS Express 2005 I have some large lookup tables (may be up to 500000 records) which contains name and id and are stored in sql server. I...
5
by: Doug | last post by:
Hi I have a simple form, just with one combo box and an OK button - and i have tried to use the autocomplete routine and I have enabled autocomplete in the combo box properties. ...
6
by: ezyeric13 | last post by:
I have a series of ComboBox's Bound to a DataGridView and I turned the AutoComplete on for them so they list all the items in a certain collumn of the DataGridView. The problem is that when you...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.