如何在DataGridView中更改特定单元格的颜色? [英] How to change color of a specific cell in DataGridView?
问题描述
我需要选择一个特定的单元格并将其背景颜色更改为红色。
private void dataGridView_CellClick (对象发送者,DataGridViewCellEventArgs e)
{
dataGridView.Rows [e.RowIndex] .Cells [e.ColumnIndex] .Style.ForeColor = Color.Red;
}
private void dataGridView_CellLeave(object sender,DataGridViewCellEventArgs e)
{
dataGridView.Rows [e.RowIndex] .Cells [e.ColumnIndex] .Style。 ForeColor = //默认颜色
}
希望能解决问题:)
I need to select a specific cell and change it background colour to red.
private void dataGridView_CellClick(object sender, DataGridViewCellEventArgs e) { dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.ForeColor = Color.Red; } private void dataGridView_CellLeave(object sender, DataGridViewCellEventArgs e) { dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.ForeColor = //default color }
Hope that solves the problem :)
这篇关于如何在DataGridView中更改特定单元格的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!