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;
        }
    }
}

posted on 2009-06-19 16:54  欣路历程  阅读(2605)  评论(2编辑  收藏  举报

导航