zoukankan      html  css  js  c++  java
  • 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);
                }
            }
    

      

  • 相关阅读:
    linux安装nginx
    python-- python threadpool 的前世今生
    如何用 Go 实现热重启
    使用expect快速登录线上机器
    curl 使用手册
    date命令时间戳和时间之间的转换
    linux设置程序运行超时时间
    你见过的最全面的python重点
    golang学习之旅:使用go语言操作mysql数据库
    Python多进程编程
  • 原文地址:https://www.cnblogs.com/Ares-blog/p/3325092.html
Copyright © 2011-2022 走看看