• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 780
  • Last Modified:

datagridview comboboxColumn event

Hello Experts,

I have a datagridview with a ComboBoxColumn and I would like to display a dialog depending on the selection from the ComboBoxColumn.  Is there a similar event like ComboBox.SelectedIndexChanged for the datagridview ComboBoxColumn?

Thank You In Advance

  • 2
1 Solution
Jorge PaulinoIT Pro/DeveloperCommented:
You have to define a DataGridViewComboBoxEditingControl
Check this example and make the necessary adjustments:

    Private WithEvents dgvCombo As DataGridViewComboBoxEditingControl
    Private Sub dgvCombo_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        If dgvCombo Is Nothing Then Exit Sub
        ' The column of the combobox
        If Me.DataGridView1.CurrentCell.ColumnIndex = 4 Then
              You code
        End If
    End Sub
    Private Sub DataGridView1_CellLeave(ByVal sender As Object, _
            ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellLeave
        dgvCombo = Nothing
    End Sub
    Private Sub DataGridView1_EditingControlShowing(ByVal sender As Object, _
            ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) _
            Handles DataGridView1.EditingControlShowing
        If TypeOf e.Control Is DataGridViewComboBoxEditingControl Then
            If dgvCombo Is Nothing Then
                dgvCombo = e.Control
            End If
            AddHandler dgvCombo.SelectedIndexChanged, _
                       New EventHandler(AddressOf dgvCombo_SelectedIndexChanged)
           End If
    End Sub

Open in new window

Jorge PaulinoIT Pro/DeveloperCommented:
'  You code
' Your code :)
mutuAuthor Commented:
Thank You!!!

I copied, pasted and modified names and voila!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now