如何在DataGridView中更改特定单元格的颜色? [英] How to change color of a specific cell in DataGridView?

查看:167
本文介绍了如何在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆