Bruce Xiao 的程序生活

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

  public void SetDataGridColor(System.Web.UI.WebControls.DataGrid dg,int Col)
  {
   //設置顯示已刪除記錄最後一列
   //DataGrid dg =  this.dginfoHeader;

   int cc=dg.Items.Count;
   //bool flg =true;
   //DataGrid中第一行的底色
   System.Drawing.Color changeColor =new System.Drawing.Color();
   
   System.Drawing.Color FirstColor =new System.Drawing.Color();
   FirstColor =System.Drawing.Color.LightBlue;
   System.Drawing.Color SecondColor =new System.Drawing.Color();
   SecondColor =System.Drawing.Color.White;
   int i=1;
   if (cc >0)
    dg.Items[i-1].BackColor =FirstColor;
    while(i<cc)
   {
    if (dg.Items[i].Cells[Col].Text ==dg.Items[i-1].Cells[Col].Text)
    {
     dg.Items[i].BackColor = dg.Items[i-1].BackColor;
    }
    else
    {
     dg.Items[i].BackColor =changeColor;
    }
    if (dg.Items[i].BackColor==FirstColor)
     changeColor=SecondColor;
    else
     changeColor=FirstColor;
   i =i+1;
   }
  }

posted on 2006-10-11 18:42  Bruce Xiao  阅读(176)  评论(0编辑  收藏  举报