Combobox in datagridview

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
 
M

Mark Bainbridge

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
 
M

Mark Bainbridge

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top