Click here to Skip to main content
15,891,253 members
Articles / Programming Languages / Visual Basic
Article

Data-bound Auto Complete Combo

Rate me:
Please Sign up or sign in to vote.
3.00/5 (12 votes)
18 Mar 2004 80.5K   393   21   10
A data-bound auto complete combo that filter items as you type.

Sample Image - DBAutoCompleteCombo.jpg

Introduction

This is a .NET auto complete combo-box component that binds to a dataset and filters combo items as you type, selecting the most similar item but showing other relatives items in the drop-down list.

Using the component

Right-click the toolbar, select add/remove itens and browse for the AutoCompleteComboBox.dll. Drag the component to the form as a normal combo-box.

Setting the data source

Use AddDataSource(DataTable,DisplayMember,ValueMember) method to set the combo data source.

VB
Dim wDataSet As New DataSet
   
wDataSet.ReadXml("data.xml")

AutoCompleteComboBox1.AddDataSource(wDataSet.Tables(0), "UserName", "UserID")

The submit event

When enter is pressed in the combo, an event "submit" is raised. The example code shows the selected text and selected value when the user press enter.

VB
Private Sub AutoCompleteComboBox1_Submit(ByVal sender As System.Object,_
 ByVal e As System.EventArgs) Handles AutoCompleteComboBox1.Submit

        Dim wComboValue As String = "(New Item)"

        If Not IsNothing(AutoCompleteComboBox1.SelectedValue) Then
           wComboValue = AutoCompleteComboBox1.SelectedValue
        End If

        lbInfo.Text = "Combo Item Text: " & _
    AutoCompleteComboBox1.SelectedText.ToString() & vbCrLf & _
    "Combo Item Code: " & wComboValue

    End Sub

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Architect
Brazil Brazil
I started development 37 years from now, since MSX basic. Started Windows programming with VB 2.0 and Web programming with ASP 3.0. Then I built Windows Forms, Web Applications, NT services and WPF applications using Microsoft.NET. I am MCP in Visual Basic 6.0, MCAD and MCSD.NET in Framework 1.1, MCPD Web in Framework 2.0, MCTS in .NET 3.5 workflow, MCTS in .NET 3.5 communication foundation, windows presentation foundation and MVC applications. Built MVC Web Application and WCF services using Micro Services architecture proposed by me. Working with AI projects to improve the business performance and customer experience. Besides programming I love running, swimming, reading and movies.

Comments and Discussions

 
GeneralThank you for this terrific source code! Pin
rodvin27-Sep-10 2:18
rodvin27-Sep-10 2:18 
GeneralRe: Thank you for this terrific source code! Pin
Daniel Liedke27-Sep-10 11:53
professionalDaniel Liedke27-Sep-10 11:53 
GeneralDon't handle base class events if you can help it. Pin
Bryan Kadzban1-Jun-05 10:12
Bryan Kadzban1-Jun-05 10:12 
QuestionWhy drop-down doesn't function? Pin
Member 157261414-Dec-04 5:55
Member 157261414-Dec-04 5:55 
AnswerRe: Why drop-down doesn't function? Pin
Member 157261414-Dec-04 6:49
Member 157261414-Dec-04 6:49 
GeneralRe: Argent Help Needed Pin
Kunal Mukherjee25-Aug-04 4:11
Kunal Mukherjee25-Aug-04 4:11 
GeneralRe: Argent Help Needed Pin
Daniel Liedke25-Aug-04 11:56
professionalDaniel Liedke25-Aug-04 11:56 
GeneralThe is exactly what I'm looking for. Pin
Vincent Ma30-Apr-04 22:39
Vincent Ma30-Apr-04 22:39 
GeneralNeed Some Help Pin
Bob Ranck26-Mar-04 5:34
Bob Ranck26-Mar-04 5:34 
Daniel,

I downloaded both files and they wont run - message says that project was in a newer version of Visual Basic yet I use Framework 1.1 You may reach me directly at the adjusted email address. Thanks
GeneralRe: Need Some Help Pin
Daniel Liedke26-Mar-04 5:52
professionalDaniel Liedke26-Mar-04 5:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.