Willy
Willy

Reputation: 10638

HOWTO: Datagridview combobox dropdowns automatically on enter (click on it)

I have a datagridview which one of its columns is a datagridviewcomboboxcolumn. So I would like combobox to dropdown automatically on enter (click on the cell). I have overrided the OnEnter method and then do a SendKeys.Send("{F4}") but it is not working.

Upvotes: 0

Views: 1602

Answers (2)

UWSkeletor
UWSkeletor

Reputation: 941

You can also set the edit mode of the datagridview to "EditOnEnter" and it would do the same thing. It would also force textbox columns to edit mode when you enter them as well.

Upvotes: 1

Willy
Willy

Reputation: 10638

Solved by handling cellEnter event:

private void OnDGVCellEnter(object sender, DataGridViewCellEventArgs e)
{
    if (e.ColumnIndex == this.colDesired.Index)
    {
        SendKeys.Send("{F4}");
    }
}

Upvotes: 1

Related Questions