I am using a DataGridView
, created using the designer with a few columns including a DataGridViewComboBoxColumn
column.
It is slightly irritating that I have to click on each cell twice or even three times to display the drop-list:
I assume it's due to the cell using the first click to get focus, but is there a way to address the issue so clicking on a cell displays the combobox right away? I note that using DataGridViewCheckBoxColumn
the same issue does not happen... clicking on a checkbox immediately toggles it regardless if that cell had focus.
You can simply set EditMode
property of your DataGridView
to EditOnEnter
.
It makes editing more easy. Almost single click, but if you want even when you click on content of combobox show dropdown for your ComboBoxColumn
immediately, you can handle CellClick
event and then use EditingControl
of your grid and cast it to DataGridViewComboBoxEditingControl
and makes it to show dropdown.
private void categoryDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
{
//You can check for e.ColumnIndex to limit this to your specific column
var editingControl = this.categoryDataGridView.EditingControl as
DataGridViewComboBoxEditingControl;
if (editingControl != null)
editingControl.DroppedDown = true;
}
Be careful when using this trick, you may make drop downs annoying for users when they only want to navigate between cells without editing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With