When I publish out and load the screen I get the error where this error occurs I get the following.
"System.ArgumentException: DataGridViewComboBoxCell value is not valid"
Additionally when a new item loads the pop up shows up until everything is loaded. When I scroll it will pop up again. I am looking what I can do to get rid of this. This is an application that has been passed on by other coworkers and I am just looking to fix it.
Private Sub Mfg_Design_Backlog()
On Error Resume Next
DataGridViewMR.Rows.Clear()
Dim Min_Factor As String = String.Empty
Dim TOTAL_SUB_V As Double = 0
Dim j As Integer
TOTAL_SUB_V = 0
Dim Comb_String As String = String.Empty
For j = 0 To ComboBoxDP.Items.Count - 1
Comb_String = Comb_String & "<>" & ComboBoxDP.Items(j)
Next
Con_DB = New ADODB.Connection
Rc_Set = New ADODB.Recordset
Con_DB.Open(ConnString)
Rc_Set = Con_DB.Execute("SELECT ID, STATUS, USER_8, DESIRED_SHIP_DATE, USER_2, USER_1,USER_3, CUSTOMER_ID, ISNULL(EDI_ACCUM_CLR_DATE,'1/1/1999') AS EDI_ACCUM_CLR_DATE, ISNULL(CONSOLIDATION_ID, '1/1/1999') AS CONSOLIDATION_ID, ISNULL(MARK_FOR_ID, '0') AS MARK_FOR_ID , ISNULL(LINK_SEQUENCE_NO,'') AS LINK_SEQUENCE_NO , " &
"ISNULL(PROJECT_ID,'N/A') AS PROJECT_ID, ISNULL(SHIPPED_FROM , 'TBA') AS SHIPPED_FROM, ISNULL(ADMINISTERED_BY,'N/A') AS ADMINISTERED_BY, ISNULL(PAY_MADE_BY,'TBA') AS PAY_MADE_BY, ISNULL(MARKED_FOR,'N/A') AS MARKED_FOR,ISNULL(OWNER_ID,'TBA') AS OWNER_ID, " &
"ISNULL(MASTER_LINK_NO,'N/A') AS MASTER_LINK_NO " &
"FROM CUSTOMER_ORDER WHERE (USER_8 = 'RTM' OR USER_8 = 'ECO') AND SITE_ID = 'CAGIL' AND DESIRED_SHIP_DATE >= '" & Today.AddMonths(-6) & "' AND NOT STATUS = 'X' AND NOT STATUS = 'C' ORDER BY 'DESIRED_SHIP_DATE' ")
Rc_Set.MoveFirst()
Do While Not Rc_Set.EOF
DataGridViewMR.Rows.Add(1)
Dim C_Box As DataGridViewComboBoxCell
C_Box = DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(3)
For j = 0 To ComboBoxDP.Items.Count - 1
C_Box.Items.Add(ComboBoxDP.Items(j))
Next
C_Box = DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(5)
For j = 0 To ComboBoxDP.Items.Count - 1
C_Box.Items.Add(ComboBoxDP.Items(j))
Next
C_Box = DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(7)
For j = 0 To ComboBoxDP.Items.Count - 1
C_Box.Items.Add(ComboBoxDP.Items(j))
Next
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(0).Value = DataGridViewMR.NewRowIndex & Rc_Set.Fields.Item("LINK_SEQUENCE_NO").Value
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(1).Value = Rc_Set.Fields.Item("ID").Value
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(2).Value = Rc_Set.Fields.Item("STATUS").Value & "-" & Rc_Set.Fields.Item("USER_8").Value
If Strings.InStr(Comb_String, Rc_Set.Fields.Item("PROJECT_ID").Value) > 0 Then
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(3).Value = Rc_Set.Fields.Item("PROJECT_ID").Value
Else
End If
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(4).Value = Rc_Set.Fields.Item("SHIPPED_FROM").Value
If Strings.InStr(Comb_String, Rc_Set.Fields.Item("ADMINISTERED_BY").Value) > 0 Then
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(5).Value = Rc_Set.Fields.Item("ADMINISTERED_BY").Value
Else
End If
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(6).Value = Rc_Set.Fields.Item("PAY_MADE_BY").Value
If Strings.InStr(Comb_String, Rc_Set.Fields.Item("MARKED_FOR").Value) > 0 Then
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(7).Value = Rc_Set.Fields.Item("MARKED_FOR").Value
Else
End If
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(8).Value = Rc_Set.Fields.Item("OWNER_ID").Value
'RELEASE
If Strings.InStr(Rc_Set.Fields.Item("SHIPPED_FROM").Value, "CMP") > 0 Then
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(3).Style.BackColor = Color.LightGreen
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(4).Style.BackColor = Color.LightGreen
ElseIf Strings.InStr(Rc_Set.Fields.Item("SHIPPED_FROM").Value, "TBR") > 0 Then ' TO BE RELEASED
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(3).Style.BackColor = Color.Yellow
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(4).Style.BackColor = Color.Yellow
Else ' NOT ASSIGNED
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(3).Style.BackColor = Color.OrangeRed
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(4).Style.BackColor = Color.OrangeRed
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(4).Value = "TBA"
End If
'CNC
If Strings.InStr(Rc_Set.Fields.Item("PAY_MADE_BY").Value, "CMP") > 0 Then
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(5).Style.BackColor = Color.LightGreen
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(6).Style.BackColor = Color.LightGreen
ElseIf Strings.InStr(Rc_Set.Fields.Item("PAY_MADE_BY").Value, "TBP") > 0 Then ' TO BE PROGRAMED
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(5).Style.BackColor = Color.Yellow
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(6).Style.BackColor = Color.Yellow
Else 'NOT ASSIGNED
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(5).Style.BackColor = Color.OrangeRed
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(6).Style.BackColor = Color.OrangeRed
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(6).Value = "TBA"
End If
'CHECK
If Strings.InStr(Rc_Set.Fields.Item("OWNER_ID").Value, "CMP") > 0 Then
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(7).Style.BackColor = Color.LightGreen
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(8).Style.BackColor = Color.LightGreen
ElseIf Strings.InStr(Rc_Set.Fields.Item("OWNER_ID").Value, "TBC") > 0 Then 'TO BE CHECKED
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(7).Style.BackColor = Color.Yellow
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(8).Style.BackColor = Color.Yellow
Else 'NOT ASSIGNED
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(7).Style.BackColor = Color.OrangeRed
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(8).Style.BackColor = Color.OrangeRed
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(8).Value = "TBA"
End If
If Strings.InStr(Rc_Set.Fields.Item("MASTER_LINK_NO").Value, "N/A") = 0 Then ' COMMENTS
DataGridViewMR.Rows(DataGridViewMR.NewRowIndex - 1).Cells(9).Value = Rc_Set.Fields.Item("MASTER_LINK_NO").Value
Else
End If
What I have tried:
I have tried a couple of different code changes to fix without luck.
Private Sub DataGridViewMR_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridViewMR.CellContentClick
**my existing code here**
' Assuming DataTable is the DataTable bound to the DataGridView
DataGridViewMR.DataSource = Nothing ' Unbind the data source
DataGridViewMR.DataSource = YourDataTable ' Rebind the data source
Catch ex As Exception
' HANDLE EXCEPTIONS APPROPRIATELY
MessageBox.Show("An error occurred: " & ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub