I'm working on a project where I use a DataGridView, with some of the columns being DataGridViewComboBoxColumn.
My users want to edit these ComboBoxCell by pressing Down key.
I've actually two ideas on how doing it:
But I didn't manage to find a way to do any of these.
So, Is there a way to achieve this? (Even if it doesn't use one of my ideas)
You can use DataGridView.KeyDown
event:
Private Sub DataGridView1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles DataGridView1.KeyDown
If e.KeyValue = Keys.Down Then
With Me.DataGridView1
If .Columns(.CurrentCell.ColumnIndex).GetType.Name = "DataGridViewComboBoxColumn" Then
If Not .IsCurrentCellInEditMode Then
.BeginEdit(True)
CType(.EditingControl, ComboBox).DroppedDown = True
e.Handled = True
End If
End If
End With
End If
End Sub
Sorry, VB.NET
code but you can easily translate it to C#
.