随笔 - 850  文章 - 37  评论 - 173  阅读 - 287万

DevExpress中XtraGrid控件对GridView每行的颜色设置 zt

改变行颜色

复制代码
private void GridView1_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e)
        {
            DevExpress.XtraGrid.Views.Grid.GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView;
            if (e.RowHandle >= 0)
            {
                string category = view.GetRowCellDisplayText(e.RowHandle, view.Columns["dS"]);
                if (category == "")
                {
                    e.Appearance.BackColor = Color.Red;
                    //e.Appearance.BackColor2 = Color.SeaShell;
                }
            }
        }
复制代码

改单元格颜色

复制代码
private void gridView1_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
         {
             if (e.Column.FieldName == "cgrbh")
             {
                 string aa = gridView1.GetRowCellDisplayText(e.RowHandle, gridView1.Columns["cgrbh"]);
                 if (aa == "6666")
                 {
                     e.Appearance.BackColor = Color.DeepSkyBlue;
                     e.Appearance.BackColor2 = Color.LightCyan;
                 }
             }
复制代码

 

posted on   武胜-阿伟  阅读(9323)  评论(2编辑  收藏  举报
努力加载评论中...

点击右上角即可分享
微信分享提示