• DEV GridControl 根据单元格值改变背景色


     GridControl 根据单元格值改变背景色(需要用到CustomDrawCell事件)

    方法1:

     private void gdvClient_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
            {
                if (e.Column.FieldName == "VerifyCN") //指定列
                {
                    if ((string)e.CellValue == "未确认")  //条件  e.CellValue 为object类型
                        e.Appearance.BackColor = Color.Red;
                }                
            }
    

    方法2:

     private void gdvStatistics_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
            {
                DevExpress.Utils.AppearanceDefault appRed = new DevExpress.Utils.AppearanceDefault
                    (Color.Black, Color.Red, Color.Empty, Color.Red, System.Drawing.Drawing2D.LinearGradientMode.Horizontal);
                DevExpress.Utils.AppearanceDefault appYellow = new DevExpress.Utils.AppearanceDefault
                    (Color.Black, Color.Yellow, Color.Empty, Color.Yellow, System.Drawing.Drawing2D.LinearGradientMode.Horizontal);
                DevExpress.Utils.AppearanceDefault appGreen = new DevExpress.Utils.AppearanceDefault
                    (Color.Black, Color.Green, Color.Empty, Color.Green, System.Drawing.Drawing2D.LinearGradientMode.Horizontal);
                if (e.Column.FieldName == "Difference")//指定列
                {
                    string strTemp = gdvStatistics.GetRowCellDisplayText(e.RowHandle, "Difference").ToString().Trim();
                    if (Convert.ToInt32(strTemp) > 0)
                        DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, appRed);
                    else if (Convert.ToInt32(strTemp) == 0)
                        DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, appGreen);
                    else
                        DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, appYellow);
                }
            }
    

      

  • 相关阅读:
    2019高考数学理科Ⅱ卷解析版[解答题]
    对风说爱你
    佛教人生-伴侣
    【Echarts每天一例】-1
    算法中涉及的专业英语
    python--随机函数(random,uniform,randint,randrange,shuffle,sample)
    【linux shell系列--1】crontab命令
    【Python爬虫实战--3】html写正则表达式
    mysql启动参数 skip-grant-tables
    php通过反射执行某方法
  • 原文地址:https://www.cnblogs.com/Ares-blog/p/3325092.html
Copyright © 2020-2023  润新知