In windows form application you can use 'AutoCompleteMode of combobox to accomplish your task, just follow the steps
1. Create one Windows Application and add DataGridView from toolbox to design.
2. Now create two DataGridViewComboBoxColumns and add them to the DataGridView:
public void ComboList1()
{
DataGridViewComboBoxColumn combo1 = new DataGridViewComboBoxColumn();
combo1.HeaderText = "fruit";
combo1.Items.Add("Apple");
combo1.Items.Add("Grapes");
combo1.Items.Add("Orange");
combo1.Items.Add("Mango");
dataGridView1.Columns.Add(combo1);
}
call above method in form constructor
Now Click on DataGridView and generate EditingControlShowing event and write the folllowing code in it:
if (e.Control is DataGridViewComboBoxEditingControl)
{
((ComboBox)e.Control).DropDownStyle = ComboBoxStyle.DropDown;
((ComboBox)e.Control).AutoCompleteSource = AutoCompleteSource.ListItems;
((ComboBox)e.Control).AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest;
}
The AutoCompleteMode and AutoCompleteSource properties create a ComboBox that automatically completes input strings by comparing the prefix being entered to the prefixes of all strings in a maintained source.