In this tutorial, I will teach you how to create an AutoComplete ComboBox in a DataGridView using C#.net. With this method, you can make the ComboBox become an Auto-Suggest and Append in the DataGridView. This method is very helpful because you don’t need to drop down and select the data in the ComboBox, all you have to do is type the first letter that you want to select. It will just automatically suggest and append the data of your selection.
So, Let’s get started.
Open Microsoft Visual Studio and create a new windows form application for C#. After that, add a DataGridView in the form and it will look like this.
Double-click the form and do the following codes for creating and adding items in the list control of a ComboBox on the first load of the form.
//Declaring variable as new DataGridViewComboBoxColumn
//That represents a column in the datagridview.
DataGridViewComboBoxColumn cbo = new DataGridViewComboBoxColumn();
//'Putting a list of items in the combobox.
//Adding a combobox in the column on the datagridview.
Go back to the Design Views, click the DataGridView and go to the properties. In the properties, hit the lightning symbol and double-click the event handler named EditingControlShowing.
After that, do the codes in the method for the AutoComplete ComboBox in the DataGridView.
//e represent the editing control in the datagridview
//the condition is, if the type of e is combobox then set your code for autocomplete
if (e.Control is ComboBox)
DataGridViewComboBoxEditingControl cbo = e.Control as DataGridViewComboBoxEditingControl;
//set the dropdown style of a combobox
cbo.DropDownStyle = ComboBoxStyle.DropDown;
//set the propety of a combobox to autocomplete mode.
cbo.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
cbo.AutoCompleteSource = AutoCompleteSource.ListItems;
For all students who need a programmer for your thesis system or anyone who needs a source code in any a programming languages. You can contact me @ :
Email – [email protected]
Mobile No. – 09305235027 – TNT