So instead of alternating every other row, I need to to alternate every other 4 rows. so a 1-4 would be blue and 5-8 would be white. I've tried to use mod and the rowindex but I keep messing up and not finding the correct way to do it, I then noticed that the data that the grid is pulling in has a column that has the same number every 4 rows. so I was thinking I can compare that value and when it changes I know that I have to change the color scheme and go for another 3 rows then switch back. below is code used and screen shot sample. it will just paint the whole grid one color.
Private Sub BTFDataGrid_RowPrePaint(sender As Object, e As DataGridViewRowPrePaintEventArgs) Handles BTFDataGrid.RowPrePaint
Dim i, ReelNum,Count As Integer
ReelNum = BTFDataGrid.Rows(0).Cells("ReelNumber").Value
For i = 1 To BTFDataGrid.Rows.Count-1
If ReelNum = BTFDataGrid.Rows(e.Rowindex).Cells("ReelNumber").Value Then
BTFDataGrid.Rows(e.RowIndex).DefaultCellStyle.BackColor = Color.LightBlue
Else
BTFDataGrid.Rows(e.RowIndex).DefaultCellStyle.BackColor = Color.WhiteSmoke
Count = Count + 1
If Count = 4 Then
ReelNum = BTFDataGrid.Rows(e.RowIndex).Cells("ReelNumber").Value
Count = 0
End If
End If
Next
' This is using index
'Dim dgv = DirectCast(sender, DataGridView)
'Dim colorIndex As Integer = If((e.RowIndex / rowStep) Mod 2 = 0, 0, 1)
'dgv.Rows(e.RowIndex).DefaultCellStyle.BackColor = rowColors(colorIndex)
'For Each row As DataGridViewRow In BTFDataGrid.Rows
' Dim colorIndex As Integer = If((row.Index / rowStep) Mod 2 = 0, 0, 1)
' BTFDataGrid.Rows(row.Index).DefaultCellStyle.BackColor = rowColors(colorIndex)
'Next
End Sub
