Getting Started with Windows Forms ComboBoxAutoComplete(Classic)
10 Oct 20223 minutes to read
Implementing a simple ComboBoxAutoComplete can be done in the following ways.
Through Designer
This tutorial illustrates the usage of the ComboBoxAutoComplete control without any external datasource.
NOTE
This is applicable only for VS2005.
-
Drag-and-drop a ComboBoxAutoComplete control from the toolbox onto the form.
-
Add items to ComboBoxAutoComplete using AutoCompleteCustomSource collection editor as shown below.
- Specify the text completion behavior of the control using ComboBoxAutoComplete.AutoCompleteMode. The value of AutoCompleteMode should not be none in this case. See Source for AutoComplete Control to know the different AutoCompleteModes.
-
Set AutoCompleteSource to CustomSource as shown below. See Source for AutoComplete Control to know the different AutoComplete sources.
Output
At runtime, type āCā in the display area of ComboBoxAutoComplete, you will see the autocompletion behavior as shown below.
Through Code
The embedded AutoComplete control in a ComboBoxAutoComplete control is exposed through the AutoCompleteControl property. The Datasource property of the AutoCompleteControl specifies the data that will be used for the auto completion of the combo box. It can be created programmatically as follows.
-
Include the required namespace.
using Syncfusion.Windows.Forms.Tools;
Imports Syncfusion.Windows.Forms.Tools
-
Create an instance of the ComboBoxAutoComplete control class.
private Syncfusion.Windows.Forms.Tools.ComboBoxAutoComplete comboBoxAutoComplete1; this.comboBoxAutoComplete1=new Syncfusion.Windows.Forms.Tools.ComboBoxAutoComplete();
Private comboBoxAutoComplete1 As Syncfusion.Windows.Forms.Tools.ComboBoxAutoComplete Me.comboBoxAutoComplete1 = New Syncfusion.Windows.Forms.Tools.ComboBoxAutoComplete()
-
Set data source and add the control to the form.
this.comboBoxAutoComplete1.AutoCompleteCustomSource.AddRange(new string[] { "Custom", "Customizing", "Customizable"}); this.comboBoxAutoComplete1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; this.comboBoxAutoComplete1.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource; this.Controls.Add(this.comboBoxAutoComplete1);
Me.comboBoxAutoComplete1.AutoCompleteCustomSource.AddRange(New String() {"Custom", "Customizing", "Customizable"}) Me.comboBoxAutoComplete1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend Me.comboBoxAutoComplete1.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource Me.Controls.Add(Me.comboBoxAutoComplete1)
-
Run the application.