让dataGrid 中特定行显示不同的颜色   比如学生信息让不及格的显示红色,及格的显示其它颜色
让dataGrid 中特定行显示不同的颜色   比如学生信息让不及格的显示红色,及格的显示其它颜色

解决方案 »

  1.   

    http://www.zahui.com/html/14/34001.htm
      

  2.   

    在ItemDataBound事件中:Cells[10]表示成绩的列
    if(e.Item.Cells[10].Text<60)
    {
       e.Item.Attributes["style"]="background-Color:red";
    }
    else
    {
       
    }
      

  3.   

    public class  DataGridColoredTextBoxColumn : DataGridTextBoxColumn
     { 
      //重载绘制单元格的函数,如果该单元格所在行符合ColoredView中的条件,就改变前景和背景色
      protected override void Paint(System.Drawing.Graphics g, 
       System.Drawing.Rectangle bounds, System.Windows.Forms.CurrencyManager 
       source, int rowNum, System.Drawing.Brush backBrush, System.Drawing.Brush 
       foreBrush, bool alignToRight) 
      { 
       /*在这里加入判断条件,决定是否更改颜色
       if (...)
        backBrush = new SolidBrush(...);
        foreBrush = new SolidBrush(...);
       */
       
       //调用基类的绘制函数
       base.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight);
      } 
     } 
      

  4.   

    直接遍历整个DataGrid,然后把符合条件的行的背景色改掉
    for(int i = 0 ; i < DataGridName.Items.Count ; i++)
    {
        if(//条件)
        {
            DataGridName.Items[i].BackColor = System.Drawing.Color.Red;
        }
    }
      

  5.   

    不明白——————————————————————————————————————
    资深C#专业QQ群组11440220 ,汇集800多位C#程序爱好者,欢迎加入,共同交流学习!
      

  6.   

    http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx
      

  7.   

    http://www.tomore.com/dispdocnew.php?id=35506
      

  8.   

    在Google上搜,很多,但不要用于商业用途,Infragistics