Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何用C语言改变windows窗体中网格视图单元格的背景色#_C#_Winforms_Gridview - Fatal编程技术网

C# 如何用C语言改变windows窗体中网格视图单元格的背景色#

C# 如何用C语言改变windows窗体中网格视图单元格的背景色#,c#,winforms,gridview,C#,Winforms,Gridview,我有一个来自数据集的填充网格视图;我想检查[4]列单元格(标题除外),如果它的单元格值小于0,它的背景将变为红色 请帮忙。。。非常感谢下面是一个在windows窗体中工作的示例 dataGridView1.Rows.Add(3, 2, -3); dataGridView1.Rows.Add(1, -2, 3); foreach (DataGridViewRow row in dataGridView1.Rows) {

我有一个来自数据集的填充网格视图;我想检查[4]列单元格(标题除外),如果它的单元格值小于0,它的背景将变为红色


请帮忙。。。非常感谢

下面是一个在windows窗体中工作的示例

        dataGridView1.Rows.Add(3, 2, -3);
        dataGridView1.Rows.Add(1, -2, 3);

        foreach (DataGridViewRow row in dataGridView1.Rows) 
        {
            if (!row.IsNewRow && int.Parse(row.Cells[2].Value.ToString()) < 0)
                row.Cells[2].Style.BackColor = Color.Red;
        }
dataGridView1.Rows.Add(3,2,-3);
dataGridView1.Rows.Add(1,-2,3);
foreach(dataGridView1.Rows中的DataGridViewRow行)
{
如果(!row.IsNewRow&&int.Parse(row.Cells[2].Value.ToString())小于0)
row.Cells[2].Style.BackColor=Color.Red;
}

根据需要设置commonHeaderCellStyle属性