Combobox in datagridview

  • Thread starter Thread starter Eric
  • Start date Start date
E

Eric

Hi,

I have a datagridview with one combobox column.
This combobox is bound to a dataset table.

Basicly it works fine with the data but the thing that is bugging me is the
amount of mouseclicks te user has to do to change the combobox value.

first click, the row is selected.
second click opens the combobox
third click is for the item selecting
fourth click is for the next row.

I would pefer to have the combo box open directly on the first click.
How can I do this, if possible?

rg,
Eric
 
First, you need to set the Edit Mode if the DataGridView:

DataGridView.EditMode = Windows.Forms.DataGridViewEditMode.EditOnEnter

Next, set the SendKey to F4 for the ComboBox:

Private Sub DataGridView_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles DataGridView.EditingControlShowing

Dim CB As Object = TryCast(e.Control, System.Windows.Forms.ComboBox)
If CB IsNot Nothing Then
My.Computer.Keyboard.SendKeys("{F4}")
End If

End Sub
 
First, you need to set the Edit Mode if the DataGridView:

DataGridView.EditMode = Windows.Forms.DataGridViewEditMode.EditOnEnter

Next, set the SendKey to F4 for the ComboBox:

Private Sub DataGridView_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles DataGridView.EditingControlShowing

Dim CB As Object = TryCast(e.Control, System.Windows.Forms.ComboBox)
If CB IsNot Nothing Then
My.Computer.Keyboard.SendKeys("{F4}")
End If

End Sub
 
Back
Top