VB.net Ich habe eine datagridview
eingerichtet mit einer Spalte gebunden an eine andere Datenbank als combobox
.System.ArgumentException: DatagridViewComboBoxCell Wert nicht gültig
Ich hatte das
System.ArgumentException: DataGridViewComboBoxCell Wert nicht gültig
ständig Fehler als ich anfing, weil es Informationen in der DB war, die nicht im combobox
war. Ich habe diese Einträge gelöscht und der Fehler scheint wegzugehen. Während ich mein Projekt durcharbeite, bekomme ich es immer noch von Zeit zu Zeit. Außerdem tritt der Fehler auf, ich schließe die Box und der DGV füllt richtig auf und alles ist in Ordnung.
Ich habe eine „bevölkern“ Knopf, der die datagridview
und die combobox
zugleich auffüllt. Ich habe versucht, die combobox
adapterfill
Anweisung nach dem Datagrid adapterfill
zu verzögern, und es scheint keinen Effekt zu haben.
Es scheint so, als ob es beim ersten Klick nur zufällig auftritt. Wenn der erste Eintrag funktioniert, kann ich erneut klicken oder einen Filter ändern und alles ist gut.
Eine weitere Sache. Es scheint zu passieren, wenn Daten in der Zelle/Zeile vorhanden sind, wenn Dinge gefüllt sind. Wenn ich alle Daten aus den Zeilen lösche, kein Fehler. Wenn ich einige Combobox-Auswahlen mache und speichere, dann befülle erneut. Ich kann den Fehler bekommen.
Hope meine Beschreibung macht Sinn.
Ich habe den Code für das Populate-Ereignis mit den Filtern enthalten. Vielen Dank.
Private Sub xP3PopulateBtn_Click(sender As Object, e As EventArgs) Handles xP3PopulateBtn.Click
Delay(1)
'Active Filters
Try
Dim strFilterP3 As String = String.Empty
'CheckBox Filtering code=Search for Incomplete Cells Line 2 Only
If xP3IncompleteCellsChkBox.Checked = True And
xP3FirstShiftChkBox.Checked = False And
xP3SecondShiftChkBox.Checked = False Then
strFilterP3 = ("(DTReasonBadgeNo Is Null Or DTEventReason Is Null Or DTReasonDateTime Is Null)")
strFilterP3 = strFilterP3 & String.Format(" And [LineID]= '3'")
ProductionDownTimeTableBindingSource.Filter = strFilterP3
ProductionDownTimeTableBindingSource.Sort = "ProductionUpDateTime desc"
End If
'CheckBox Filtering code=Search for Incomplete Cells on first and second shift only Lines 1N and 1S Only
If xP3IncompleteCellsChkBox.Checked = True And
xP3FirstShiftChkBox.Checked = True And
xP3SecondShiftChkBox.Checked = True Then
strFilterP3 = ("(DTReasonBadgeNo Is Null Or DTEventReason Is Null Or DTReasonDateTime Is Null) And (Shift = 1 Or Shift = 2)")
strFilterP3 = strFilterP3 & String.Format(" And [LineID]= '3'")
ProductionDownTimeTableBindingSource.Filter = strFilterP3
ProductionDownTimeTableBindingSource.Sort = "ProductionUpDateTime desc"
End If
'CheckBox Filtering code=Search for Incomplete Cells on first shift only Line 2 Only
If xP3IncompleteCellsChkBox.Checked = True And
xP3FirstShiftChkBox.Checked = True And
xP3SecondShiftChkBox.Checked = False Then
strFilterP3 = ("(DTReasonBadgeNo Is Null Or DTEventReason Is Null Or DTReasonDateTime Is Null) and Shift = 1")
strFilterP3 = strFilterP3 & String.Format(" and [LineID]= '3'")
ProductionDownTimeTableBindingSource.Filter = strFilterP3
ProductionDownTimeTableBindingSource.Sort = "ProductionUpDateTime desc"
End If
'CheckBox Filtering code=Search for Incomplete Cells on second shift only Line 2 Only
If xP3IncompleteCellsChkBox.Checked = True And
xP3FirstShiftChkBox.Checked = False And
xP3SecondShiftChkBox.Checked = True Then
strFilterP3 = ("(DTReasonBadgeNo Is Null Or DTEventReason Is Null Or DTReasonDateTime Is Null) and Shift = 2")
strFilterP3 = strFilterP3 & String.Format(" and [LineID]= '3'")
ProductionDownTimeTableBindingSource.Filter = strFilterP3
ProductionDownTimeTableBindingSource.Sort = "ProductionUpDateTime desc"
End If
'CheckBox Filtering Code=Incomplete and Complete Cells on First Shift Only Line 2 Only
If xP3IncompleteCellsChkBox.Checked = False And
xP3FirstShiftChkBox.Checked = True And
xP3SecondShiftChkBox.Checked = False Then
strFilterP3 = "Shift = 1"
strFilterP3 = strFilterP3 & String.Format(" and [LineID]= '3'")
ProductionDownTimeTableBindingSource.Filter = strFilterP3
ProductionDownTimeTableBindingSource.Sort = "ProductionUpDateTime desc"
End If
'CheckBox Filtering Code=Incomplete And Complete Cells on Second Shift Only Line 2 Only
If xP3IncompleteCellsChkBox.Checked = False And
xP3FirstShiftChkBox.Checked = False And
xP3SecondShiftChkBox.Checked = True Then
strFilterP3 = "Shift = 2"
strFilterP3 = strFilterP3 & String.Format(" and [LineID]= '3'")
ProductionDownTimeTableBindingSource.Filter = strFilterP3
ProductionDownTimeTableBindingSource.Sort = "ProductionUpDateTime desc"
End If
'CheckBox Filtering Code=S how All Line 2 Only
If xP3IncompleteCellsChkBox.Checked = False And
xP3FirstShiftChkBox.Checked = False And
xP3SecondShiftChkBox.Checked = False Then
strFilterP3 = "1 = 1"
strFilterP3 = strFilterP3 & String.Format(" and [LineID]= '3'")
ProductionDownTimeTableBindingSource.Filter = strFilterP3
ProductionDownTimeTableBindingSource.Sort = "ProductionUpDateTime desc"
End If
'CheckBox Filter Code Show all Data from First and Second Shift Line 2 Only
If xP3IncompleteCellsChkBox.Checked = False And
xP3FirstShiftChkBox.Checked = True And
xP3SecondShiftChkBox.Checked = True Then
strFilterP3 = ("(Shift = 1 Or Shift = 2)")
strFilterP3 = strFilterP3 & String.Format(" And [LineID]= '3'")
ProductionDownTimeTableBindingSource.Filter = strFilterP3
ProductionDownTimeTableBindingSource.Sort = "ProductionUpDateTime desc"
End If
'This line of code loads data into the 'ProductionDownTimeDataSet.ProductionDownTimeTable' table.
Me.ProductionDownTimeTableTableAdapter.Fill(Me.ProductionDownTimeDataSet1.ProductionDownTimeTable)
'After Binding the DataSource to the ComboBox in the DatGrid, this populates the data
Me.DTCodeDataTableAdapter.Fill(Me.DownTimeCodesDataSet.DTCodeData)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Toller Rat! Ich verstehe jetzt, warum dies geschah. Ich habe den Code geändert und konnte das Ereignis nicht mehr neu erstellen. Danke für die Hilfe! – sds5150
@ sds5150 Kein Problem! Ich bin froh, dass es geklappt hat! Glückliche Kodierung! – ic3man7019