有人提过,但发现方法有问题。
特开帖请大虾们进来请几句。

解决方案 »

  1.   

    if(控件.value="fale")
    {
      DataGridView1.Attributes.Add("style","BACKGROUND-COLOR: #99cc66"")
    }
      

  2.   

    private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
     {
    if (dataGridView1.Columns[e.ColumnIndex].Name.Equals("Sex"))
    {
        if (e.Value=="女")
        {
            e.CellStyle.BackColor =Color.Red;
        }
        
    }
    }
      

  3.   

    juedaihuaihuai(绝代坏坏(beyond myself)) 
    根本就是乱讲。sz709("钱"途越渺茫...,越要拼命学...) (
    你的方法不能实现目标呀,没能反应。
      

  4.   

    '第0行第1列的背景色---红色 ,方法一
    sGrid.Rows(0).Cells(1).Style .BackColor=Color.Red
    '第1行的背景色---红色
    sGrid.Rows(1).DefaultCellStyle.BackColor = Color.Red方法二
    If not sGrid.EditingControl Is Nothing Then 
    '设置当前编辑列的背景色
    sGrid.EditingControl.BackColor = Color.Red
    end if
      

  5.   

    不好意思,上次的代码错误,这次测试通过了,请楼主看看private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
    {
    if (dataGridView1.Columns[e.ColumnIndex].Name.Equals("Sex"))
    {
        DataGridViewCell cell = dataGridView1[e.ColumnIndex, e.RowIndex];
        String stringValue = e.Value as string;
        if (stringValue == null)
        {
            return;
         }
        switch (stringValue.Trim())
        {
            case "女":
                e.CellStyle.BackColor = Color.Red;
                break;
        }
    }
    }
      

  6.   

    protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
        {            if (GridView1.Rows[e].Cells[i].Text == "女")//如果每行的第i列值等于女就把这行变成红色色!
                    GridView1.Rows[e].BackColor = Color.Red; 
          
            
        }
      

  7.   

    sz709("钱"途越渺茫...,越要拼命学...) 还是不行呀。请问dataGridView1_CellFormatting这个事件都是在什么时候发生?
      

  8.   

    怎么这么多人分不清Winform里面的DataGridView和asp.net里面的GridView呢???
    看着这些答案都好笑