I've looked at other posts, but I didn't see where I went wrong.
(review attached screenshot for a better understanding)
In my situation, I add background color to row cells where this is an "A" value in the cell. This stands for an aisle in a warehouse.
If you scroll slowly, then the background color stays within the rows with an "A", but if you scroll too fast, the display shows green in various cells. Also, if I clear the grid and rebuild it with new data, the background color is not reset. The previous rows that were green are still green.
What am I missing?
01.
Private
Sub
dgvMain_CellFormatting(sender
As
Object
, e
As
CellFormattingEventArgs)
Handles
dgvMain.CellFormatting
02.
If
_LeftOrRightConveyor =
"LEFT"
And
e.CellElement.ColumnIndex = AisleColumnLeft_Idx
Then
03.
e.CellElement.BackColor = System.Drawing.Color.LightGreen
04.
ElseIf
_LeftOrRightConveyor =
"RIGHT"
And
e.CellElement.ColumnIndex = AisleColumnRight_Idx
Then
05.
e.CellElement.BackColor = System.Drawing.Color.LightGreen
06.
End
If
07.
08.
If
e.CellElement.Value =
"A"
Then
09.
e.CellElement.BackColor = System.Drawing.Color.Lime
10.
End
If
11.
End
Sub