如何通过编程方式将货币格式添加到 AspxPivotGrid 中的数据行?

How to add currency format to Data Row in AspxPivotGrid by Programmatically?

我想将货币格式添加到 AspxPivotGrid 中的数据行 table。 你可以看到下面的图片,它现在是如何显示的。所以我只想将货币格式显示到 3 个字段 (ExtendedPrice,ExtendedCost,Profit)

这是我的 C# 代码:

if (i == 8 || i == 9 || i == 10 || i == 11)
{
    DevExpress.Web.ASPxPivotGrid.PivotGridField newF = new DevExpress.Web.ASPxPivotGrid.PivotGridField(names[i], PivotArea.DataArea);
    newF.ID = "field" + newF.FieldName;
    //newF.ValueFormat.FormatType=
    ASPxPivotGrid1.Fields.Add(newF);
}

这可能对你有用

newF.ValueFormat-FormatString = "c2";
newF.ValueFormat-FormatType = "Numeric";

根据此文档 (FormatInfo) 我认为应该这样设置:

newF.ValueFormat.FormatType = FormatType.Numeric;
newF.ValueFormat.FormatString = "c2";