如何通过VALUE更改datagrindview的背景颜色 [英] How do I change the backcolor of datagrindview via VALUE
本文介绍了如何通过VALUE更改datagrindview的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不知道问题出在哪里?有人可以帮帮我吗?
I don't know where the Problem is? Can somebody help me please?
this.dataGridView2.Columns["Status"].VALUE == "2".DefaultCellStyle.BackColor = Color.Yellow;
< b>我尝试了什么:
没有价值它适合 - 但我需要用VALUE改变颜色
What I have tried:
Without Value it fits - but i Need to change the Color with VALUE
推荐答案
列没有值。您需要读取您感兴趣的行上的单元格值,并更改该单元格的颜色。
A column does not have a value. You need to read the value of the cell on the row you're interested in, and change that cell's colour.
DataGridViewCell cell = this.dataGridView2.Rows[THE_ROW_INDEX].Cells["Status"];
if (cell.Value == "2")
{
cell.Style.BackColor = Color.Yellow;
}
在列中尝试此选项:
Try this for column:
dataGridView2.Columns["Status"].DefaultCellStyle.BackColor = Color.Yellow;
或单元格:
or this for cell:
if (dataGridView1.Rows[0].Cells[0].Value == "2")
dataGridView2.Rows[0].Cells[0].Style.BackColor = Color.Yellow;
这篇关于如何通过VALUE更改datagrindview的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文