Results 1 to 7 of 7

Thread: [RESOLVED] Datagridview Combobox SelectedIndexChanged

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2009
    Posts
    43

    Resolved [RESOLVED] Datagridview Combobox SelectedIndexChanged

    Ive got an example from the web regarding catching the indexchange of a datagridview combobox column. My datagridview is unbound, has got one combobox column and could have multiple rows. When i implement the code below, the indexchange fires even upon selection or when a datagridview combobox from another row is selected.This fires even before actually selecting from the dropdown list of the combobox itself... it will show the initial index and text of the combobox upon focus even before you could select from the pull down... hope somebody could help me... thanks

    Code:
    Private Sub dgvDeparture_EditingControlShowing(ByVal sender As Object, ByVal e As DataGridViewEditingControlShowingEventArgs) Handles dgvDeparture.EditingControlShowing
    
                   Dim editingComboBox As ComboBox = CType(e.Control, ComboBox)
            If Not editingComboBox Is Nothing Then
                AddHandler editingComboBox.SelectedIndexChanged, AddressOf editingComboBox_SelectedIndexChanged
            End If
            'RemoveHandler editingComboBox.SelectedIndexChanged, _
            'New EventHandler(AddressOf editingComboBox_SelectedIndexChanged)
        End Sub
        Private Sub editingComboBox_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
    
            Dim cboCell As ComboBox = CType(sender, ComboBox)
            MessageBox.Show(cboCell.SelectedIndex.ToString()) ' Display index
            MessageBox.Show(cboCell.Text) ' Display value
    
        End Sub
    Last edited by pidyok; Jul 28th, 2011 at 02:41 AM. Reason: addt'l description

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width