Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

WPF Autocomplete Textbox Control

, 31 May 2008 CPOL
An article showing how to build a WPF autocomplete textbox control with delay input
wpfautocompletetextbox_demo.zip
Release
WPFAutoCompleteTextbox.exe
WPFAutoCompleteTextbox.pdb
WPFAutoCompleteTextbox.vshost.exe
WPFAutoCompleteTextbox.vshost.exe.manifest
wpfautocompletetextbox_src.zip
WPFAutoCompleteTextbox
WPFAutoCompleteTextbox
bin
Release
WPFAutoCompleteTextbox.vshost.exe
WPFAutoCompleteTextbox.vshost.exe.manifest
Properties
Settings.settings
WPFAutoCompleteTextbox.csproj.user
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WPFAutoCompleteTextbox
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
            textBox1.AddItem(new AutoCompleteEntry("Toyota Camry", "Toyota Camry", "camry", "car", "sedan"));
            textBox1.AddItem(new AutoCompleteEntry("Toyota Corolla", "Toyota Corolla", "corolla", "car", "compact"));
            textBox1.AddItem(new AutoCompleteEntry("Toyota Tundra", "Toyota Tundra", "tundra", "truck"));
            textBox1.AddItem(new AutoCompleteEntry("Chevy Impala", null));  // null matching string will default with just the name
            textBox1.AddItem(new AutoCompleteEntry("Chevy Tahoe", "Chevy Tahoe", "tahoe", "truck", "SUV"));
            textBox1.AddItem(new AutoCompleteEntry("Chevrolet Malibu", "Chevrolet Malibu", "malibu", "car", "sedan"));
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            textBox1.Text = string.Empty;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

thomastn

United States United States
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141223.1 | Last Updated 31 May 2008
Article Copyright 2008 by thomastn
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid