如何解决如何启用DevExpress网格条件格式?
我有一个.net,C#Windows Form项目。我正在使用DevExpress 19.1。在我的GridControl上,当列小于0时,我有条件格式。当值小于0时,我希望该单元格突出显示为红色,但它不起作用。我尝试过使用表达式,条件和值,仅适用于一列,适用于整个角色,但我始终无法突出显示。有人可以告诉我我在做什么错吗?
以下是该规则在代码中的显示方式:
gridFormatRule3.ApplyToRow = true;
gridFormatRule3.Column = this.colQuantityLeft;
gridFormatRule3.ColumnApplyTo = this.colQuantityLeft;
gridFormatRule3.Name = "Format0";
formatConditionRuleValue3.Appearance.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))),((int)(((byte)(128)))),((int)(((byte)(128)))));
formatConditionRuleValue3.Appearance.Options.UseBackColor = true;
formatConditionRuleValue3.Condition = DevExpress.XtraEditors.FormatCondition.Less;
formatConditionRuleValue3.Expression = "[QuantityLeft] < 0";
formatConditionRuleValue3.Value1 = 0;
gridFormatRule3.Rule = formatConditionRuleValue3;
this.gvProducts.FormatRules.Add(gridFormatRule3);
这是我在设计器中设置规则的方式:
在输出中,您可以看到该值小于0并且背景颜色保持不变:
解决方法
我看到网格中只有一行。网格总是有焦点的行。聚焦行外观的优先级高于条件外观。禁用GridView.OptionsSelection.EnableAppearanceFocusedCell和GridView.OptionsSelection.EnableAppearanceFocusedRow属性以删除焦点所在的行外观。
this.gvProducts.OptionsSelection.EnableAppearanceFocusedCell = false;
this.gvProducts.OptionsSelection.EnableAppearanceFocusedRow = false;
或者,将FormatConditionRuleValue.Appearance.Options.HighPriority属性设置为true
。
formatConditionRuleValue3.Appearance.Options.HighPriority = true;
,
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。