private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
if (e.RowIndex >= 0 && e.ColumnIndex == dataGridView1.Columns["status"].Index)
{
string precision = Convert.ToString(e.Value);
if (precision == "5")
{
e.Value = "完工";
dataGridView1.Rows[e.RowIndex].DefaultCellStyle.ForeColor = System.Drawing.Color.Blue; }
else if (precision == "1")
{
e.Value = "插单";
dataGridView1.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.Green;
}
else
{
e.Value = "正常";
dataGridView1.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.Red;
}
e.FormattingApplied = true;
}
怎么报错:"未将对象引用设置到对象的实例。"可以确定e.RowIndex >0.大家帮忙看下
if (e.RowIndex >= 0 && e.ColumnIndex == dataGridView1.Columns["status"].Index)
{
string precision = Convert.ToString(e.Value);
if (precision == "5")
{
e.Value = "完工";
dataGridView1.Rows[e.RowIndex].DefaultCellStyle.ForeColor = System.Drawing.Color.Blue; }
else if (precision == "1")
{
e.Value = "插单";
dataGridView1.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.Green;
}
else
{
e.Value = "正常";
dataGridView1.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.Red;
}
e.FormattingApplied = true;
}
怎么报错:"未将对象引用设置到对象的实例。"可以确定e.RowIndex >0.大家帮忙看下
解决方案 »
- 求助用avicap32.dll的API捕获摄像头信息,回调函数中的信息是什么格式,怎么还原为BMP图像,谢谢
- 什么时候lock
- 如何预判?
- 如何将C:\windows\shell32.dll,4这种形式转换为Icon输出
- VS2005快捷键不能用了,大家帮个忙
- 部署问题
- 我想要一个字体大小的集合就是那种 小四 小五之类的 有没有像取字体集合InstallFontCollection的那种类
- 【求助】为什么读取的 汉字字符串的 单数个字的个数总是少一个?多谢!
- 未处理NullReferenceException
- WPF,请看下这个UserControl
- 请教页面抓取:抓取不到Table中的内容;
- 查询框的 下拉显示部分,怎么加上滚动条>?
把dataGridView1_CellFormatting事件去掉能显示10多条数据出来,status里全都不为NULL!
红色的是列名还是,列上面显示的文字?