private void DataGridView_RowPostPaint(object sender,
DataGridViewRowPostPaintEventArgs e)
{
DataGridView dgv = (DataGridView)sender;
// 行に色をつける
if (e.RowIndex % 2 == 0)
{
// 偶数行
dgv.Rows[e.RowIndex].DefaultCellStyle.BackColor =
CommonInfo.DataGridViewEvenRowBackColor;
}
else
{
// 奇数行
dgv.Rows[e.RowIndex].DefaultCellStyle.BackColor =
CommonInfo.DataGridViewOddRowBackColor;
}
// 選択行の前景色セット
dgv.Rows[e.RowIndex].DefaultCellStyle.SelectionForeColor =
CommonInfo.DataGridViewSelectionRowForeColor;
// 選択行の背景色セット
dgv.Rows[e.RowIndex].DefaultCellStyle.SelectionBackColor = CommonInfo.DataGridViewSelectionRowBackColor;
}