【问题标题】:Is there a way to to autoformat a row in DevExpress GridView winforms?有没有办法在 DevExpress GridView winforms 中自动格式化一行?
【发布时间】:2012-10-24 00:41:37
【问题描述】:

我有一个 DevExpress GridControl,它绑定到一个具有 foo 对象集合的 BindingList。

foo 拥有以下成员:

string name;

int qty;

(属性有get/setter并实现INotifyPropertyChanged

我想要完成的是假设数量更改为 0,则行颜色=绿色,如果

显然,一种方法是设置一个事件来捕获每个数据更改,然后根据这种条件进行评估,然后格式化,但我认为应该有一种更简单的方法? 有什么想法吗? 谢谢。

【问题讨论】:

    标签: c# gridview devexpress autoformatting


    【解决方案1】:

    您可以通过设置Style Format Conditions 来做到这一点,这可以在设计器中或通过代码来完成。

    在代码中设置:

    var condition1 = new StyleFormatCondition(FormatConditionEnum.Greater, gridColumnQty, null, 0);
    condition1.Appearance.BackColor = Color.Green;
    condition1.ApplyToRow = true;
    gridView1.FormatConditions.Add(condition1);
    
    var condition2 = new StyleFormatCondition(FormatConditionEnum.Less, gridColumnQty, null, 0);
    condition2.Appearance.BackColor = Color.Red;
    condition2.ApplyToRow = true;
    gridView1.FormatConditions.Add(condition2);
    

    【讨论】:

    • 谢谢!明白了,但现在看来我有另一个问题。如果我的网格是蒙皮的(例如,使用像蓝图这样的标准 DevX 皮肤),需要在那里添加其他东西吗?有什么想法吗?
    • @Gregory Grantt 我将皮肤与 StyleFormatCondition 一起使用没有问题。你遇到了什么问题?
    猜你喜欢
    • 1970-01-01
    • 2012-07-17
    • 2021-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多