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?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
You can achieve this by subscribing for the
EditingControlShowing
event of the grid and there for control of typeComboBox
And in the Enter event, use the property
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.
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:
Now the ComboBox drops down faster and the user still delete a row by selecting a row and pressing DEL key.
That's it.
Set
EditMode
property of theDataGridView
toEditOnEnter
: linkDataGridView.EditMode
- Gets or sets a value indicating how to begin editing a cell.EditOnEnter
- Editing begins when the cell receives focus.