I am trying to get the selected value of a combo box in a datagridview, but i have not found any thing that works.
I found this code but i get an error object reference not set to an instandce of an object at the location in red
Private Sub dgv1_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles dgv1.EditingControlShowing
If e.Control.GetType() Is GetType(DataGridViewComboBoxEditingControl) Then
Dim cbo As ComboBox = e.Control
RemoveHandler cbo.SelectionChangeCommitted, AddressOf cboOnSelectionChangeCommitted
AddHandler cbo.SelectionChangeCommitted, AddressOf cboOnSelectionChangeCommitted
End If
End Sub
Private Sub cboOnSelectionChangeCommitted(ByVal sender As Object, ByVal e As EventArgs)
Dim cbo As ComboBox = CType(sender, ComboBox)
Console.WriteLine(cbo.SelectedValue.ToString())
MsgBox(cbo.SelectedValue.ToString())
End Sub