環境:NET2003
datagrid 中相關屬性的設置行有﹕行號﹐料號﹐描述﹐庫存量﹐單位
我想把﹕1.庫存量>某值(如﹕1000)的庫存量值變為紅色。
        2.庫存量>某值(如﹕1000)的行的所有字體變為紅色。
注意我不想改變整行背景色

解决方案 »

  1.   

    protected void DataGridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //写判断
            }
        }
      

  2.   

    if(convert.ToInt32(e.Row.Cells[你要比较列的索引0开始].Controls[0]) > 1000)
    {
        //要改变的东西
    }这个是在每行加载数据的时候会判断次(没用过2003``但是应该有``)
      

  3.   

    对不起``请在e.Row.Cells[你要比较列的索引0开始].Controls[0]后加.text``不然没参数的``前面的只能找到那个控件``因为手写的``所以没注意``呵呵``
      

  4.   

    饿``我的问题``e.Row.Cells[0].ForeColor = System.Drawing.Color.Red;这样就第一列字体红色``在判断里写``
    修改cell的索引就可以换列了``
      

  5.   

    protected   void   DataGridView1_RowDataBound(object   sender,   GridViewRowEventArgs   e) 

          if   (e.Row.RowType   ==   DataControlRowType.DataRow) 
          { 
              if(convert.ToInt32(e.Row.Cells[你要比较列的索引0开始].Controls[0].text)   >   1000) 
              { 
                  for (int nI = 0; nI < e.Row.Cells.Count; nI++)
                  {
                    e.Row.Cells[1].ForeColor = System.Drawing.Color.Red;
                  }           
               } 
           } 
    }最后就是这样了
      

  6.   

    for   (int   nI   =   0;   nI   <   e.Row.Cells.Count;   nI++) 

           e.Row.Cells[1].ForeColor   =   System.Drawing.Color.Red; 
    }      e.Row.Cells[1].ForeColor   里的1改成nI