Ho trovato il seguente codice
codice:
Private Sub DataGridView4_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles DataGridView4.EditingControlShowing
If DataGridView4.CurrentCell.ColumnIndex = 0 And Not e.Control Is Nothing Then
Dim combo As ComboBox = DirectCast(e.Control, ComboBox)
AddHandler combo.SelectedIndexChanged, AddressOf ComboBox_SelectedIndexChanged
AddHandler combo.Leave, AddressOf ComboBox_Leave
End If
End Sub
Private Sub ComboBox_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim combo As ComboBox = DirectCast(sender, ComboBox)
DataGridView4.Item(1, DataGridView4.CurrentRow.Index).Value = ARTICOLIBindingSource.Item(combo.SelectedIndex)
Debug.WriteLine(combo.SelectedValue)
End Sub
Private Sub ComboBox_Leave(ByVal sender As Object, ByVal e As System.EventArgs)
Dim combo As ComboBox = DirectCast(sender, ComboBox)
Debug.WriteLine("leave index " & combo.SelectedIndex)
RemoveHandler combo.SelectedIndexChanged, AddressOf ComboBox_SelectedIndexChanged
RemoveHandler combo.Leave, AddressOf ComboBox_Leave
End Sub
e sono riuscito a intercettare quando si cambia l'items alla combo!!!
Percio ora il resto è tutto fattibile!!!
Ancora una domanda:
nel mio databinding che ho usato per stampare il codice_articolo nella combo, ho inserito anche il campo articolo, nella riga in rosso ho provato a richiamare il campo della query e ho provato a stamparlo ma non funziona.
Posso usare il databinding per scrivere l'articolo oppure faccio prima a fare una query???
Grazie
Ciao