AutoComplete TextBox In WPF

No.of Views1581
Bookmarked0 times
Downloads 
Votes0
By  dpatra   On  16 Apr 2010 11:04:40
Tag : WPF , Edit Controls
This article is a simple approach for achieving AutoComplete for TextBox.
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 

Introduction

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


Creating WPF Application Project

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

Image Loading

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.  

Image Loading

 

Image Loading

Now we would write code to achieve this.Create a sample data, in our case it is List of Strings.
 

Image Loading

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

Image Loading

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. 

Image Loading

That’s it. Run the application. 

Image Loading

You can design the suggestion style as per your requirement.Hope this article helps.
 

Sample Project Code

Download source files -44 kb

 
Sign Up to vote for this article
 
About Author
 
dpatra
Occupation-Not Provided
Company-Not Provided
Member Type-Expert
Location-Not Provided
Joined date-13 Jul 2009
Home Page-Not Provided
Blog Page-Not Provided
 
 
Other popularSectionarticles
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top