我想在鼠标悬停在特定单元格上时更改datagridview中单元格的背景色。
尝试过的代码:
private void dataGridView_whateventwillcomehere(object sender, DataGridViewCellEventArgs e)
{
}
最佳答案
在CellMouseMove
事件上尝试
private void dataGridView1_CellMouseMove(object sender, DataGridViewCellMouseEventArgs e)
{
dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = Color.Blue;
}
您需要
CellMouseLeave
事件以恢复颜色private void dataGridView1_CellMouseLeave(object sender, DataGridViewCellEventArgs e)
{
dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = Color.White;
}
关于c# - datagridview单元格鼠标悬停背景色更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31337566/