I am currently working in Visual Studio Express 2013. I have often changed the colors of cells based on an IF statement to represent the data but now i am trying to run code based on a cell color.I am having a hard time figuring this one out. The DGV I am using is link to an SQL back end. Here is what I am trying:
Dim max As Integer = DGVJobs.Rows.Count - 1
Dim total As String = "------>"
Dim AssemHoursTotal As Integer = 0
Dim BodyHoursTotal As Integer = 0
For Each row As DataGridViewRow In DGVJobs.Rows
If Not .rows(row).cells("AssemHours").defaultcellstyle.backcolor = Color.Orange = True Then
AssemHoursTotal += row.Cells("AssemHours").Value
BodyHoursTotal += row.Cells("BodyHours").Value
End If
Next
MsgBox(AssemHoursTotal)
MsgBox(BodyHoursTotal)
My error occurs on the line where "If Not .Rows.....". I need to loop through these 2 columns to sum the contents but not include any rows with an orange back color.
Aucun commentaire:
Enregistrer un commentaire