CellFormatting事件绑定判断
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (e.ColumnIndex == 1 /*status列的Index*/)
{
if (object.Equals(e.Value, 0))
{
e.Value = "未完成";
e.CellStyle.ForeColor = Color.Red;
}
else
{
e.Value = "已完成";
e.CellStyle.ForeColor = Color.Green;
}
}
}
{
if (e.ColumnIndex == 1 /*status列的Index*/)
{
if (object.Equals(e.Value, 0))
{
e.Value = "未完成";
e.CellStyle.ForeColor = Color.Red;
}
else
{
e.Value = "已完成";
e.CellStyle.ForeColor = Color.Green;
}
}
}