Hello!
I'm trying to color the rows in my DataGridView by groups, all rows with the same date will be one color, then the next group with the same date will be a different color, something like this:
![Name: DGV.jpg
Views: 129
Size: 54.5 KB]()
The real data in my table is this:
![Name: Tabla.jpg
Views: 40
Size: 38.1 KB]()
In another post a nice member on this forum explain to me the steps to achieve the goal, he even help me with most of the task sharing the following code.
But I'm getting this error in line 10:
System.IndexOutOfRangeException: 'Índice fuera de los límites de la matriz.
Help please!
I'm trying to color the rows in my DataGridView by groups, all rows with the same date will be one color, then the next group with the same date will be a different color, something like this:
The real data in my table is this:
In another post a nice member on this forum explain to me the steps to achieve the goal, he even help me with most of the task sharing the following code.
VB:NET Code:
Dim distinctValues = DataGridView1.Rows. Cast(Of DataGridViewRow)(). Select(Function(row) CStr(row.Cells("Hora_para_cancelar").Value)). Distinct(). ToArray() Dim allColors = {Color.Yellow, Color.Blue} Dim colorsByDate As New Dictionary(Of String, Color) For i = 0 To distinctValues.GetUpperBound(0) colorsByDate.Add(distinctValues(i), allColors(i)) Next
But I'm getting this error in line 10:
System.IndexOutOfRangeException: 'Índice fuera de los límites de la matriz.
Help please!