日期:2014-05-17 浏览次数:20997 次
private void dataGridViewX4_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
{
//所以行号的背景色
for (int i = 0; i < this.dataGridViewX4.Rows.Count; i++)
{
if (i % 2 == 0)
{
dataGridViewX4.Rows[i].DefaultCellStyle.BackColor = Color.Lavender; //偶数行浅蓝色
}
}
}
private void dataGridViewX4_CellMouseEnter(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex > 0)
dataGridViewX4.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Khaki;
return;
}
private void dataGridViewX4_CellMouseLeave(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex > 0)
{
if (e.RowIndex % 2 == 0)
{
dataGridViewX4.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Lavender; //偶数行浅蓝色
}
else
dataGridViewX4.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.White;
}
return;
}