C#的DataGridView中某一单元格显示颜色怎么弄啊?

解决方案 »

  1.   


    private   void   dataGridView1_RowPrePaint(object   sender,   DataGridViewRowPrePaintEventArgs   e) 
                    { 
                            if   (e.RowIndex   > =   dataGridView1.Rows.Count   -   1) 
                                    return; 
                            DataGridViewRow   dgr   =   dataGridView1.Rows[e.RowIndex]; 
                            try 
                            { 
                                    if   (dgr.Cells[ "列名 "].Value.ToString()   ==   "比较值 ") 
                                    { 
                                            dgr.DefaultCellStyle.ForeColor   =   设置的颜色; 
                                    } 
                            } 
                            catch   (Exception   ex) 
                            { 
                                    MessageBox.Show(ex.Message); 
                            } 
                    } http://www.cnblogs.com/Echang/articles/1030596.html
      

  2.   

    dataGridView.Rows[行号].Cells["列明"].Style.BackColor = Color.Red;
      

  3.   

    dataGridView[列号,行号].Style.BackColor = Color.Red;
      

  4.   

    dataGridView.Rows[行号].Cells["列明"].Style.BackColor = Color.Red;