我有一个绑定到可观察集合的DevXPress GridControl。我想格式化“WorkedHours”但不知何故不起作用,所以结果看起来很难看。这是代码:
<dxg:GridControl ItemsSource="{Binding Result}">
<dxg:GridControl.TotalSummary>
<dxg:GridSummaryItem SummaryType="Sum" FieldName="Worked" DisplayFormat="0.0"/>
</dxg:GridControl.TotalSummary>
<dxg:GridControl.Columns>
<dxg:GridColumn Header="Month" DisplayMemberBinding="{Binding Path=Month}" Visible="{Binding Path=GroupByMonth}" Width="80"/>
<dxg:GridColumn Header="Name" DisplayMemberBinding="{Binding Path=Name}" Visible="{Binding Path=ShowName}" Width="220"/>
<dxg:GridColumn Header="Project code" DisplayMemberBinding="{Binding Path=ProjectCode}" Visible="{Binding Path=ShowProjects}" Width="80" />
<dxg:GridColumn Header="Project description" DisplayMemberBinding="{Binding Path=ProjectDescription}" Visible="{Binding Path=ShowProjects}" Width="270"/>
<dxg:GridColumn Header="Wbs code" DisplayMemberBinding="{Binding Path=WbsCode}" Visible="{Binding Path=ShowWbs}" Width="80" />
<dxg:GridColumn Header="Wbs description" DisplayMemberBinding="{Binding Path=WbsDescription}" Visible="{Binding Path=ShowWbs}" Width="270" />
<dxg:GridColumn Header="Comment" DisplayMemberBinding="{Binding Path=Comment}" Visible="{Binding Path=ShowComment}" Width="270" />
<dxg:GridColumn Header="Worked hours" DisplayMemberBinding="{Binding Path=Worked,StringFormat=\{0\:N0\}}" Width="100" FieldName="Worked" />
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView AllowGrouping="True" ShowAutoFilterRow="True" ShowTotalSummary="True"/>
</dxg:GridControl.View>
</dxg:GridControl>
有关如何修复它的任何想法?非常感谢。我尝试了不同的格式化选项,但没有一个能像人们期望的那样工作。
答案 0 :(得分:1)
更改StringFormat =&gt; StringFormat=N0
答案 1 :(得分:1)
这似乎是DevExpress中的一个错误,请参阅以下链接:
https://www.devexpress.com/Support/Center/p/Q257296.aspx
他们建议使用GridColumn.EditSettings
附加属性来代替..