0

I am using DevExpress XtraGrid to show data. I would like to show the negative numbers in parenthesis. Numbers include both positive and negative numbers.

Eg:

123.448
-234.887
-35687.98753
87654.98765

etc...

I want to format them as below

123.448
(234.887)
(35,687.98753)
87,654.98765

What would be the format string that needs to be used, to get the above result?

4

3 回答 3

0
settings.Columns.Add(set =>
                    {
                        set.FieldName = "myField";
                        set.Caption = "myFieldCaption";
                        set.UnboundType = DevExpress.Data.UnboundColumnType.String;
                        set.UnboundExpression = "Iif([myField] < 0, '(' +[myField]+ ')', [myField])";
                    });

在 mvc 中是这样完成的,但我不知道它是如何在 winforms 中完成的。

于 2012-06-14T08:38:36.237 回答
0

请在您的列编辑器上使用自定义数字掩码:

this.gridColumn1.ColumnEdit = this.repositoryItemTextEdit1;
//...
this.repositoryItemTextEdit1.Mask.EditMask = "###,###,###,##0.0##;(###,###,###,##0.0##)";
this.repositoryItemTextEdit1.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;
this.repositoryItemTextEdit1.Mask.UseMaskAsDisplayFormat = true;
于 2011-12-08T06:13:21.123 回答
0

您始终可以使用 GridView.CustomColumnDisplayText 事件来更改数据的外观。不过,使用面具要整洁得多。

于 2011-12-12T10:09:59.813 回答