gpt4 book ai didi

c# - datagridview单元格鼠标悬停背景色更改

转载 作者:太空宇宙 更新时间:2023-11-03 18:05:39 24 4
gpt4 key购买 nike

我想在鼠标悬停在特定单元格上时更改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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com