2

I have a Datagridview in Winform. One of the column is a Combobox. Is it possible to set the property such that user can enter apart from being able to select the entries from the dropdown list.

I was able to do it on a Combobox item with a following changes from the properties window:

AutoCompleteMode.SuggestAppend;
AutoCompleteSource.CustomSource;
DropDownStyle : Dropdown;

Thanks

Philip Kirkbride
  • 21,381
  • 38
  • 125
  • 225
Kiran
  • 8,034
  • 36
  • 110
  • 176

1 Answers1

6

Something like this may Help :-

private void DataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
    if (DataGridView1.CurrentCell.ColumnIndex == yourComboBoxColum)
    {
        ComboBox combo = e.Control as ComboBox;

        if (combo == null)
            return;

        combo.DropDownStyle = ComboBoxStyle.DropDown;
    }
}
Mo Patel
  • 2,321
  • 4
  • 22
  • 37
Derek
  • 8,300
  • 12
  • 56
  • 88
  • Thanks a lot, It did make the combox cell editable. However, since I have setup the Datagridview in Virtual mode, I am not able to push the new value to the underlying class object. It always revert back to the previous value. Any idea why it might be happening? – Kiran Dec 07 '12 at 11:04
  • Cant help you with that, Ive not used virtual mode. – Derek Dec 07 '12 at 11:35