How to create editable combobox cell in DataGridView

When you develop business applications, DataGridView is a really useful control. 
However, sometime we run into a similar problem.

A DataGridViewComboBoxColumn don't have a DropDownStyle property.
You can't change the style of in DataGridView,
it's limited to DropDownList style by default.

In an EditingControlShowing event of DataGridView, you can change style to DropDown.

private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlsShowingEventArgs e)
{
if (dataGridView1.CurrentCellAddress.X == column1.DisplayIndex) {
ComboBox cb = e.Control as ComboBox;
if (cb != null)
{
  cb.DropDownStyle = DropDown;
}
}
}


Only above code, it will occur a DataError exception, because Items don't include the data
that the user typed data. Generally, you can avoid this problem by adding user typed data to Items in CellValidating event.

private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
    if (dataGridView1.CurrentCellAddress.X == column1.DisplayIndex) {
        if (!column1.Items.Contains(e.FormattedValue) {
            column1.Items.Add(e.FormattedValue);
}
}
}

In this way, you can create editable in DataGridView.

There are some problems with the interface yet.
A cursor in this don't move on arrow key. 
If you want to use arrow key in this editable column, 
you have to override IDataGridViewEditingContorl...

--