問一下WinForm的DataGridView,
我知道可以每一格顯示不同的顏色,
但現在有一個需求,
希望一格裡面的上面一行跟下面一行,
顯示不同的顏色,
不知道這個功能有辦法做到嗎?
麻煩大大幫忙回答一下了,
謝謝~

private void dataGridView1_DataBindingComplete
(object sender, DataGridViewBindingCompleteEventArgs e)
{
    int index = 0;
    int spliteCell = 3;//每三行換一個顏色
    foreach (DataGridViewRow dgv in dataGridView1.Rows)
    {
        if(index % spliteCell == 0)
            row.DefaultCellStyle.BackColor = Color.Red; //改row的顏色
        else if(index % spliteCell == 1)
            row.DefaultCellStyle.BackColor = Color.Blue; //改row的顏色
        else if(index % spliteCell == 2)
            row.DefaultCellStyle.BackColor = Color.Yellow; //改row的顏色
            
        index++;
    }
}
你的需求是這樣嗎?
不能去找到 DataGridView 的id,然後用CSS解決嗎?
https://www.w3schools.com/cssref/sel_nth-child.asp