我想知道如何为datagridview的前8行着色。我已设法按降序对值进行排序,并且我希望前8行着色以突出显示用户的前8位,并且我不确定如何执行此操作。
Dim count As Integer
For count = 0 To datagridsort.RowCount - 1
Do
datagridsort.Rows(0).Cells(0).Style.BackColor = Color.Coral
datagridsort.Rows(0).Cells(1).Style.BackColor = Color.Coral
Loop Until count = 8
Next
答案 0 :(得分:0)
在您在评论中发布的代码中,您从未使用 count 变量。您每次只更新第一行。试试这样:
For i As Integer = 0 To Math.Min(datagridsort.RowCount - 1, 7)
For j As Integer = 0 To datagridsort.ColumnCount - 1
datagridsort.Rows(i).Cells(j).Style.BackColor = Color.Coral
Next
Next