Solved

datagridview comboboxColumn event

Posted on 2008-10-10
3
761 Views
Last Modified: 2010-04-21
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

Mutu
0
Comment
Question by:mutu
  • 2
3 Comments
 
LVL 48

Accepted Solution

by:
jpaulino earned 250 total points
ID: 22689943
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

0
 
LVL 48

Expert Comment

by:jpaulino
ID: 22689951
'  You code
is
' Your code :)
0
 

Author Closing Comment

by:mutu
ID: 31505151
Thank You!!!

I copied, pasted and modified names and voila!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Disable extension 8 48
Convert datetime to time string 10 28
Complex SQL statement in VB.NET 7 31
Optimize the query 5 43
This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question