datagridview 单元格鼠标悬停背景色改变
datagridview cell mouse hover backcolor change
我想在鼠标悬停在特定单元格上时更改 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;
}
我想在鼠标悬停在特定单元格上时更改 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;
}