1

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
Kat
  • 2,460
  • 2
  • 36
  • 70

2 Answers2

2

Change the EditMode property:

DataGridView1.EditMode = DataGridViewEditMode.EditOnEnter
LarsTech
  • 80,625
  • 14
  • 153
  • 225
1

There seems to be a nearly identical question and a very good answer. It involves using the click_event. Here is the link: How to manually drop down a DataGridViewComboBoxColumn?

In the link:

Private Sub cell_Click(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles      DataGridView1.CellClick
    DataGridView1.BeginEdit(True)
    If DataGridView1.Rows(e.RowIndex).Cells(ddl.Name).Selected = True Then
        DirectCast(DataGridView1.EditingControl, DataGridViewComboBoxEditingControl).DroppedDown = True
    End If
End Sub
Community
  • 1
  • 1
Sastreen
  • 597
  • 4
  • 13
  • So, is this more changing the style of the combobox? Maybe that might be another solution? – Kat Jul 08 '14 at 18:15