SIGN UP MEMBER LOGIN:    
ARTICLE

AutoComplete Textbox in WPF

Posted by Diptimaya Patra Articles | WPF with C# January 30, 2010
This article is a simple approach for achieving AutoComplete for TextBox.
Reader Level:
Download Files:
 

Introduction

I have gone through a lot of AutoComplete TextBox in WPF articles. This article is a simple approach for achieving AutoComplete for TextBox.

Crating WPF Application Project

Fire up Visual Studio 2008 and Create a WPF Application and name the project as AutoCompleteWPF.

image1.gif

Here is the basic things we need to do for achieving AutoComplete feature for a TextBox.

First we need to have a TextBox and a ListBox. You can see the below screenshot and xaml for reference.

image2.gif

image3.gif

Now we would write code to achieve this.

Create a sample data, in our case it is List of Strings.

image4.gif

Now in TextChanged event we need to write the below code:

image5.gif

As we would see the suggestion would pop up and we can select on the particular item write the below code for SelectionChanged event of ListBox.

image6.gif
That's it. Run the application.

image7.gif

You can design the suggestion style as per your requirement.

Hope this article helps.

Login to add your contents and source code to this article
share this article :
post comment
 

yes its simple.. and helpful. but not exactly a AutoComplete Textbox

Posted by chetan jagetia Sep 22, 2011

This is very limited. It is just showing the list of matching words bt u cannot select them as we can do in google search..

Posted by chetan jagetia Sep 22, 2011

Really great example.  And you keep it simple and to the point.  Good Job!

Posted by Greg Frazier Oct 04, 2010
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Team Foundation Server Hosting
Become a Sponsor