472,780 Members | 1,120 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,780 software developers and data experts.

ComboBox Autocomplete feature

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 the next

Here are instructions how to do it:


There is one bug, though.

If you click the expansion error and then type text into the dropdown
entry box to find a match entry, the new value will not be saved by the
ComboBox. For some reason even though the values are registered on the
SelectedIndexChanged event, the new selected values are lost by the
LostFocus event.

I found one solution that reset the values in the LostFocus event but
it didn't work for me. What did work for me was doing this:

Private Sub AutoComboBox_SelectedIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
' Need to maintain the selected values internally due to
combobox selection bug
m_selectedIndex = Me.SelectedIndex
m_selectedValue = Me.SelectedValue
m_selectedText = Me.Text
End Sub

Which maintains the values internally upon the selectedIndexChanged
event. And then reset it in the LostFocus event:

Private Sub AutoComboBox_LostFocus(ByVal sender As Object, ByVal e
As System.EventArgs) Handles MyBase.LostFocus

' Need to set the selected values internally due to combobox
selection bug
Me.SelectedIndex = m_selectedIndex
Dim valType As Type = m_selectedValue.GetType()
Dim val2Type As Type = Me.SelectedValue.GetType()

If Not m_selectedValue Is Nothing And valType Is val2Type Then
Me.SelectedValue = m_selectedValue
End If
Me.Text = m_selectedText

End Sub

Nov 21 '05 #1
0 1679

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

Similar topics

by: Alex | last post by:
Hello, does anybody know how to turn off the autocomplete feature for a certain text field? I am aware of the "autocomplete" attribute, but I have seen other implementions achieving it...
by: VM | last post by:
How can I implement the autocomplete functionality in a Windows comboBox? Thanks.
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. ...
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...
by: Becker | last post by:
I have a need for a simple combobox on a form in one of my programs that represents city, state. I want to have it autocomplete as the user types. I have a table with these values (about 50k of...
by: Kalvin | last post by:
I found some code in Google, don't remember where, for an AutoComplete combobox. Everything is great with it except for one thing. If I use the mouse to drop the list down, then start typing to...
by: =?Utf-8?B?UmljaA==?= | last post by:
Greetings, I have to load 30,000 unique names into a combox. Filling a dataTable takes only a few milliseconds. But populating the combobox and displaying the list takes several seconds - way...
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...
by: =?Utf-8?B?UiBSZXllcw==?= | last post by:
Hi - I've been searching around for a fix but can't find one... There is a bug with combobox autocomplete suggestappend. When text has a slash, "ab/cd" for example, the autocomplete feature cuts...
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.