winform中的datagridview,某个cell的背景色,怎么根据字段设置背景色?

解决方案 »

  1.   

            private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
            {
                if (e.RowIndex == 1 && e.ColumnIndex == 1)
                {
                    e.CellStyle.BackColor = Color.Red;
                }
            }
      

  2.   

    cell的属性里没有.BlackColor属性么?根据字段的话可以做个判断,符合你的条件就什么颜色,我试过整个row的颜色,cell的颜色设置还没试过,楼主可以尝试下