zoukankan      html  css  js  c++  java
  • Devexpress GridView 数据根据不同条件格式化显示色块和文字颜色

    1.色块和文字颜色方法

    /// <summary>
    /// 设置单元格样式(色块)
    /// </summary>
    /// <param name="gc">Devexpress GridView </param>
    /// <param name="color">颜色</param>
    /// <param name="expression">表达式(条件)</param>
    /// <returns></returns>
    protected virtual StyleFormatCondition SetStyleFormatCondition(GridColumn gc, Color color, string expression)
    {
    StyleFormatCondition condition1 = new DevExpress.XtraGrid.StyleFormatCondition();
    condition1.Column = gc;
    condition1.Appearance.BackColor = color;
    condition1.Appearance.Options.UseBackColor = true;
    condition1.Condition = FormatConditionEnum.Expression;
    condition1.Expression = expression;
    return condition1;
    }

    /// <summary>
    /// 设置单元格(字体颜色)
    /// </summary>
    /// <param name="gc">Devexpress GridView</param>
    /// <param name="color">颜色</param>
    /// <param name="expression">表达式(条件)</param>
    /// <returns></returns>
    protected virtual StyleFormatCondition SetStyleFormatFontCondition(GridColumn gc, Color color, string expression)
    {
    StyleFormatCondition condition1 = new DevExpress.XtraGrid.StyleFormatCondition();
    condition1.Column = gc;
    condition1.Appearance.ForeColor = color;
    condition1.Appearance.Options.UseForeColor = true;
    condition1.Appearance.Options.UseTextOptions = true;
    condition1.Condition = FormatConditionEnum.Expression;
    condition1.Expression = expression;
    return condition1;
    }

    2.开始调用

    gvData.FormatConditions.Add(SetStyleFormatCondition(gvData.Columns["AuditStatus"], Color.FromArgb(56, 173, 40), "AuditStatus=='已审核'"));//审核状态(色块)

    gvData.FormatConditions.Add(SetStyleFormatFontCondition(gvData.Columns["OrderStatus"], Color.FromArgb(30, 119, 194), "OrderStatus=='未完成'"));//执行状态(文字颜色)

    执行结果:

  • 相关阅读:
    $.ajax()、$.post()、$.get()
    Json数据格式
    iOS UIButton 调节文字和图片的位置
    block 中使用 weakSelf
    iOS 移除导航栏黑线
    Swift 设置导航栏透明
    Xcode 8 证书管理 Signing for "xxxx" requires a development team.
    iOS 中文登录 中文参数 转码
    ios apple pay 证书配置
    Missing iOS Distribution signing identity for ... Xcode can request one for you.
  • 原文地址:https://www.cnblogs.com/qq-xiao/p/6094405.html
Copyright © 2011-2022 走看看