Click here to Skip to main content
6,597,576 members and growing! (20,355 online)
Email Password   helpLost your password?
Desktop Development » Combo & List Boxes » General     Intermediate

Auto Complete Multi Column ComboBox

By cavoliotmail.com1@h

This is my version of an auto completing mutli column ComboBox.
C#, Windows, .NET 1.1VS.NET2003, Dev
Posted:6 Oct 2005
Views:70,257
Bookmarked:39 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
11 votes for this article.
Popularity: 3.58 Rating: 3.44 out of 5
2 votes, 18.2%
1

2

3
1 vote, 9.1%
4
8 votes, 72.7%
5

Sample Image

Introduction

I have seen a few other multi column combo boxes and auto complete combo boxes so I decided to submit this code that does both.

Background

A while ago I needed to move a project from MS Access to C#. In Access it was using a lot of their nifty columned combo boxes and our customers would struggle mightily if there were any changes to this functionality. Thus the ColumnComboBox was born.

Using the code

This class can be used like any other ComboBox except the Items should be set using the Data property. This is a DataTable from which the ColumnComboBox gets all the data for filling the drop down box. Simply fill a DataTable as desired and then set the Data property with it.

//set the Data of the ColumnComboBox

myColumnComboBox.Data = myDataTable;

You can then set the column that will be displayed as the text of the combo box.

//set the ViewColumn

myColumnComboBox.ViewColumn = 2;

Any columns that you don't want to display in the drop down can be hidden like this:

//Set a few columns to not be shown

myColumnComboBox.Columns[1].Display = false;
myColumnComboBox.Columns[3].Display = false;

There are a few other properties to play with such as being able to turn auto complete off (myColumnComboBox.Suggest = false;) or an indexer for getting values from columns at the current rows.

Points of Interest

The code uses a few helper classes that are included either below the ColumnComboBox class or in another included file (StringList). The source for the ColumnComboBox is commented if you want to poke around yourself. I for one will be happier when/if they get templates into C#.

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

About the Author

cavoliotmail.com1@h


Member

Location: United States United States

Other popular Combo & List Boxes articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 22 of 22 (Total in Forum: 22) (Refresh)FirstPrevNext
Questionhow to use in datagridview Pinmembermkhalid00712:11 9 Jul '09  
Generalcolumn headers Pinmemberarevans7:07 19 Nov '08  
GeneralRe: column headers Pinmemberewansw5:43 30 Dec '08  
Generalget only one value PinmemberJM ® - DE CASTRO4:22 30 Apr '08  
GeneralRTL PinmembernETbKA5:34 19 Apr '07  
GeneralRe: RTL Pinmembercavoli16:12 19 Apr '07  
GeneralRe: RTL PinmembernETbKA23:37 21 Apr '07  
GeneralRe: RTL Pinmembercavoli15:01 23 Apr '07  
GeneralIndexed items with sorted list Pinmemberdave.kelly22:11 28 Feb '07  
GeneralRe: Indexed items with sorted list Pinmembercavoli16:05 1 Mar '07  
GeneralRe: Indexed items with sorted list Pinmemberdave.kelly21:55 1 Mar '07  
GeneralRe: Indexed items with sorted list Pinmembercavoli16:14 1 Mar '07  
GeneralSet Selected Index Pinmembersalah_gis0:35 22 Feb '07  
GeneralRe: Set Selected Index Pinmembercavoli16:13 1 Mar '07  
QuestionMouse pointer dissapears Pinmemberfonk66611:01 8 Feb '07  
AnswerRe: Mouse pointer dissapears Pinmembercavoli15:00 9 Feb '07  
AnswerRe: Mouse pointer dissapears Pinmembersanrio55513:50 13 Mar '07  
GeneralI can't find the control in my toolbox Pinmemberbigwill343410:35 10 Dec '06  
GeneralRe: I can't find the control in my toolbox Pinmembercavoliotmail.com1@h4:47 12 Dec '06  
GeneralRe: I can't find the control in my toolbox Pinmembervicspainhower6:56 30 Dec '08  
AnswerRe: Setting the SelectedIndex Pinmembercavoli15:15 16 Nov '05  
GeneralRe: Setting the SelectedIndex Pinmembercavoli15:28 21 Nov '05  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 6 Oct 2005
Editor: Smitha Vijayan
Copyright 2005 by cavoliotmail.com1@h
Everything else Copyright © CodeProject, 1999-2009
Web17 | Advertise on the Code Project