【发布时间】:2014-12-26 20:03:08
【问题描述】:
我有一个 WPF 项目,其中包含一个带有 Infragistics xamDataGrid 的表单。此 xamDataGrid 中显示的数据会因调用者而异。
我想要做的是格式化一个数字列 (Rate) 以显示 4 个小数位。我找到了几个站点,其中包含有关如何使用 XAML 执行此操作的说明,但是由于此网格中的数据是动态的,因此我需要在代码隐藏中执行此操作。 (最好是 C#,但我可以用 VB.NET 来管理。)
调用者当前将要在网格中显示的数据以及要隐藏的列和可编辑的列传递给我。所以我可以让它给我一个要格式化的列列表和要使用的格式字符串。
我只需要弄清楚如何告诉 xamDataGrid 以某种方式格式化列或字段。
对于那些想要查看 XAML 的人,这里是数据网格:
<igWPF:XamDataGrid x:Name="GrdMaint"
Margin="10"
DataSource="{Binding Source={StaticResource cvsDataGrid}}"
BorderBrush="Black"
BorderThickness="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
IsSynchronizedWithCurrentItem="True"
Theme="Office2k7Blue"
GroupByAreaLocation="None"
FieldLayoutInitialized="GrdMaint_OnFieldLayoutInitialized"
PreviewMouseDoubleClick="GrdMaint_OnPreviewMouseDoubleClick"
RecordUpdated="GrdMaint_RecordUpdated">
<igWPF:XamDataGrid.FieldSettings>
<igWPF:FieldSettings AllowRecordFiltering="True"
FilterLabelIconDropDownType="MultiSelectExcelStyle"
Width="Auto" />
</igWPF:XamDataGrid.FieldSettings>
<igWPF:XamDataGrid.FieldLayoutSettings>
<igWPF:FieldLayoutSettings HighlightAlternateRecords="True"
FilterUIType="LabelIcons"
AllowDelete ="False"
AutoGenerateFields="True" />
</igWPF:XamDataGrid.FieldLayoutSettings>
</igWPF:XamDataGrid>
【问题讨论】:
标签: wpf infragistics xamdatagrid