How can i avoid the double click on a DropDownButton
used within a DataGridView
? Right now I am able to view the drop down items within the DataGridView
by clicking two or more times. First time it selects the cell and second time when I click on the DropDownButton
arrow, it shows the list. How can I achieve the same in a single click?
-
Can you elaborate on as what you want to achieve – V4Vendetta Jun 14 '11 at 10:52
-
@V4Vendetta,i'd updated the description. Please check. – NewBie Jun 14 '11 at 10:55
-
You may want to check [this solution.](http://stackoverflow.com/questions/34543940/datagridviewcomboboxcolumn-doesnt-open-the-dropdown-on-first-click/39757746#39757746) – TaW Sep 28 '16 at 21:18
3 Answers
You can achieve this by subscribing for the EditingControlShowing
event of the grid and there for control of type ComboBox
ComboBox ctl = e.Control as ComboBox;
ctl.Enter -= new EventHandler(ctl_Enter);
ctl.Enter += new EventHandler(ctl_Enter);
And in the Enter event, use the property
void ctl_Enter(object sender, EventArgs e)
{
(sender as ComboBox).DroppedDown = true;
}
DroppedDown indicates as the name suggests whether the dropdown area is shown or not, so whenever the control is entered this will set it to true and display the items without the need of further clicks.

- 37,194
- 9
- 78
- 82
-
i need to display the dropitems on clicking the datagrid cell itself. This gives no difference. – NewBie Jun 14 '11 at 11:21
-
13Can you set DataGridView EditMode = `DataGridViewEditMode.EditOnEnter` – V4Vendetta Jun 14 '11 at 11:23
-
that alone did the job.I set the EditMode = EditOnEnter property only and that's now working.Thanks. – NewBie Jun 14 '11 at 11:35
-
code in this anwser opens dropdown when you click on datagridview's gray area.this is unwanted behaviour to me so i used this (which uses CellEnterEvent to trigger dropdown ): http://stackoverflow.com/questions/13005112/how-to-activate-combobox-on-first-click-datagridview1 – bh_earth0 Dec 10 '16 at 17:02
-
This is not a valid answer to this question because there is no Enter event for a DataGridViewComboxCell control. – Obi Wan Dec 27 '16 at 19:08
The "set EditMode property of the DataGridView to EditOnEnter" worked for me, but I found another problem: user can't delete a row by just selecting and pressing DEL key. So, a google search gave me another way to do it. Just catch the event CellEnter and check if the cell is the appropriated type to perform appropriated action like this sample code:
private void Form_OnLoad(object sender, EventArgs e){
dgvArmazem.CellEnter += new DataGridViewCellEventHandler(dgvArmazem_CellEnter);
}
void dgvArmazem_CellEnter(object sender, DataGridViewCellEventArgs e)
{
DataGridView dg = (DataGridView)sender;
if (dg.CurrentCell.EditType == typeof(DataGridViewComboBoxEditingControl))
{
SendKeys.Send("{F4}");
}
}
Now the ComboBox drops down faster and the user still delete a row by selecting a row and pressing DEL key.
That's it.

- 131
- 1
- 5
-
I experience this interesting behaviour - the first click expands the dropbox, selects the first item, and instantly closes the dropbox. I need to click again in order to actually make my selection. – valsidalv Dec 03 '13 at 20:28