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);
                }
            }
    

      

  • 相关阅读:
    app接口开发(php)
    eclipse JRE(unbound)问题
    HTTP状态码详解
    HTTP方法
    项目开发注意事项及技巧
    JavaWeb 路径问题
    POJ 3264 Balanced Lineup(RMQ_ST)
    了解NoSQL
    多表查询(章节摘要)
    ios UITableView 获取点击cell对象
  • 原文地址:https://www.cnblogs.com/Ares-blog/p/3325092.html
Copyright © 2011-2022 走看看