[英]C# Set Color for 1 Cell in DataGridView
您应该设置DataGridViewCell.Style
属性。
看看这个例子
private void DataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex < 0 || e.RowIndex == dataGridView1.NewRowIndex)
{
return;
}
var dataGridViewCellStyle =
new DataGridViewCellStyle(dataGridView1.DefaultCellStyle)
{
BackColor = Color.Gold
};
dataGridView1[e.ColumnIndex, e.RowIndex].Style = dataGridViewCellStyle;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.