vb.netdatagridviewdatagridviewcombobox

Changing double clicking activation on Combo box cell to single click?


I have a setup in my code where there is a datagridview. For each row I have a combo box cell that I have a separate combo box cell since I want a different selection of items for each cell.

Problem : The cell only drops down when the arrow is double clicked. How can I change the cell formatting, or possibly a cell click event, so that the cell response to just one click?

Here's my cell creation code. Frankly, I didn't start any other code since I didn't know what event to touch or call. Is there a property I can edit?

Code:

           'add items to combobox list 
            Dim comboCell As New DataGridViewComboBoxCell 
            comboCell.FlatStyle = FlatStyle.Flat
            Dim resolutionList As New List(Of cmbStruct)

            Dim currentResIndex As Integer = 0

            'create list of resolutions
            For j As Integer = 0 To resolutions.Length - 1

                Dim resClass As New cmbStruct
                resClass.Name = resolutions(j)
                resClass.ID = resolutions(j)
                resolutionList.Add(resClass)
                comboCell.Items.Add(resolutions(j))

              Next

            'set combocell values
            comboCell.DisplayMember = "Name"
            comboCell.ValueMember = "ID"

           'set the default value to the current resolution index 

            Try
                comboCell.Value = resolutions(currentResIndex) 
            Catch ex As Exception

            End Try

            comboCell.ValueType = GetType(cmbStruct)
            comboCell.DataSource = resolutionList
            editCameraTable("Resolution", i) = comboCell

        Next

Solution

  • Change the EditMode property:

    DataGridView1.EditMode = DataGridViewEditMode.EditOnEnter