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

      

  • 相关阅读:
    JS之显式类型转换(最全)
    Python如何以两个字符一行方式输出"Hello World"
    封装localstorage为插件挂载到vue原型上
    封装localstorage 为方法
    input radio checkbox选中的c's's
    vue-插件 引用ali.JS,
    时间相加减
    mall-vue 门店版
    account.vue 以及continuePay.vue 通过action 里面的ajax后去支付
    service/axios.js
  • 原文地址:https://www.cnblogs.com/Ares-blog/p/3325092.html
Copyright © 2011-2022 走看看