我是Devexpress的新手。现在我需要任何人的帮助才能继续。我在Windows应用程序中有一个gridcontrol。 gridcontrol中的数据使用EntityFramework无限制。里面有很多列。有两列名为AmountDroppped和TransactionAmount。我需要添加另一列来显示这些列之间的差异,如果此自定义列值大于400INR,我想使整行变红。有没有办法在不使用代码隐藏和存储过程的情况下执行此操作。希望可能有一个。
答案 0 :(得分:0)
我建议您使用Unbound Columns功能及其Expressions来实现显示两个绑定列之间差异的自定义列:
using DevExpress.XtraGrid.Columns;
//...
GridColumn columnDiff = new GridColumn();
columnDiff.FieldName = "amountDiff";
columnDiff.Caption = "Diff";
columnDiff.UnboundType = DevExpress.Data.UnboundColumnType.Decimal;
columnDiff.UnboundExpression = "[TransactionAmount] - [AmountDroppped]";
gridView1.Columns.Add(columnDiff);
要有条件地突出显示某些特定行,我建议您使用Style Format Conditions功能:
using DevExpress.XtraGrid;
StyleFormatCondition condition = new DevExpress.XtraGrid.StyleFormatCondition();
condition.Appearance.BackColor = Color.Red;
condition.Appearance.Options.UseBackColor = true;
condition.ApplyToRow = true;
condition.Condition = FormatConditionEnum.Expression;
condition.Expression = "([TransactionAmount] - [AmountDroppped]) > 400";
gridView1.FormatConditions.Add(condition);
相关的帮助文章:Design-Time Features > Grid Designer > Style Format Conditions Page