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




Reply With Quote