How can I set a NumberFormat (like "#,##0.00") for Columns in a Grid? I don't find an appropriate Property in FieldSettings.
Hi,
For that you need to set the EditorStyle property of the FieldSettings. Format and FormatProvider are exposed on the editors themselves. Something like this:
<Style TargetType="{x:Type dge:ValueEditor}" >
<Setter Property="Format" Value="yyyy/mm/dd"/>
</Style>
</dg:FieldSettings.EditorStyle>
Hope this helps,
Sandip
Is there anyway to do this during run time in the C# code.
The user preference for how to display Date information is stored on the server and can be different for each user.
How can I do this during run time ?
I'm not sure what you mean by updating the grid. If you're having a problem then you may want to contact the support group and provide a sample that demonstrates the problem. You should be able to handle the InitializeFieldLayout event and initialize the FieldSettings there.
There isn't a way to force the event to fire again since it has already been initialized and the style has already been applied to the cells in view so while it will affect new cells brought into view it will not affect the cells already in view. You should be able to set the Format property (using the same setter syntax) and provide a Binding that you would use to provide the dynamically changed format but I tried this out and the editor will not update the display until the value has been changed. I've submitted an issue for this. You should report the issue to support group and reference issue #10470 so you can be notified when the issue is addressed.
I just received a notification that this bug was fixed (Case# CAS-11603-99T5EY - Fix for Issue# 10470).
What would be the right way to use it now – how can I change the number format on already loaded values?
Was it already fixed in the initial 2009.1 version? If not is there a patch for the XamDataGrid Express version?
Thank you in advance.
Hello,
This is resolved in the release of NetAdvantage for Win Client 2009 Volume 1: WPF .
As for the right way to use it, I would recommend exposing a property for the format on an object that can be used for the DataContext of your Window. Then you can set up a binding on the editor for the Format property to the property exposed on the DataContext.
For example if your custom object exposes a string property "Format", then you could use the following when the editor is used with a XamDataGrid:
<Setter Property="Format" Value="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Window}},Path=DataContext.Precision}" />
When you wish to update the format used by the grid, simply change the property on your custom object.
Let me know if you have any questions with this matter.
Alan
Thanks a lot. It works great now.
Boris