Lotok
Well-known member
I have a datagrid control on a winform. During the process of data manipulation, via form button presses, the code will highlight some Cells (ones containing errors).
when an error is detected I have an arraylist of string arrays. My initial thinking was to input the row index and column name in the array which works ok until the datagrid column is clicked to sort. At that time the indexes all change and the wrong cells remain highlighted.
I am looking for ideas on how to track the index change so I can move the highlighted cell accordingly.
Here is the code for colouring the cell
when an error is detected I have an arraylist of string arrays. My initial thinking was to input the row index and column name in the array which works ok until the datagrid column is clicked to sort. At that time the indexes all change and the wrong cells remain highlighted.
I am looking for ideas on how to track the index change so I can move the highlighted cell accordingly.
Here is the code for colouring the cell
Private Sub dgMain_CellFormatting(sender As Object, e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles dgMain.CellFormatting For i = 0 To arrErrors.Count - 1 Step 1 Dim r() As String = arrErrors(i) Dim rw As DataGridViewRow = dgMain.Rows(r(0)) rw.Cells(r(1)).Style.BackColor = Color.Red Next updateStatus(arrErrors.Count & " Errors") End Sub