// RowPostPaint 이벤트를 이용한 각 행에 대한 배경색 변경하기
private void dGridView_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
string remain_sec = string.Empty;
try
{
remain_sec = dGridView[5, e.RowIndex].Value.ToString().Replace("초","");
int sec = Convert.ToInt32(remain_sec);
if (sec <= 값1)
dGridView.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Red;
else if (sec <= 값2)
dGridView.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(255, 128, 0);
else if (sec <= 값3)
dGridView.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(192, 192, 0);
else if ( sec <= 값4 )
dGridView.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(0, 192, 0);
else
dGridView.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Empty;
if (e.RowIndex == 0)
{
dGridView.RowsDefaultCellStyle.SelectionBackColor = dGridView.Rows[e.RowIndex].DefaultCellStyle.BackColor;
dGridView.RowsDefaultCellStyle.SelectionForeColor = Color.White;
}
}
catch
{ }
}