I am using v15.2 win grid
We are using custom culture information. I can set the columns format and formatinfo appropriately, however when it comes to setting the summary displayformat for a column, the formatting does not come out correctly.
Currently this is what I tried but it does not format correctly for the culture I am trying to test.
e.Layout.Bands[0].Summaries["myColSum"].DisplayFormat = "{0:n}";
I have used "{0:##,##0}", but that does not format the display to the correct culture.
How do I get this to work?
Hi,
Your question doesn't really have anything specifically to do with the grid. The way the format works is that the grid just calls ToString on the value and passes in the format. I'm not sure if there are localized formats, but if so, it would depends on the data type of your summary.
Standard Numeric Format Strings
Custom Numeric Format Strings
Also, I think if you don't specify any format at all, then the summary value will pick up the format from the system settings. I'm guessing that maybe you are using the DisplayFormat just to remove the text that appears by default before the summary value. So in that case, you would just do this:
e.Layout.Bands[0].Summaries["myColSum"].DisplayFormat = "{0}";
I tried the following without success:
e.Layout.Bands[0].Summaries["ssalepr"].DisplayFormatProvider = CultureInfo.CurrentCulture;
e.Layout.Bands[0].Summaries["ssalepr"].DisplayFormat = "{0:n0}";
and I tried just {0} but it did not work either.
Again... this is nothing to do with the grid. You could try the same thing using any value in code. My guess is that "n0" simply isn't a localizable format.The Dotnet framework handles the formatting.
What's the DataType of the column you are trying to format?
Hi Mike,
I realize its not the grid. The underlying datatype is decimal for the column.
So if you are using "n0", then your summary will never display a decimal point. Therefore, the only affect culture would have on your summary is the thousands separator.
So I created a test app the formats a decimal value in both a cell and in a summary and where you can experiment with different formats and choose between two cultures. I chose US-English (because that's the default on my system) and German. I picked German because I happen to know that German uses a decimal point (.) instead of a comma (,) for the thousands separator.
And this works fine for me. When running under US English culture, the summary is displayed using a comma as the separator and when run under German culture, the summary shows with a decimal point as the separator.
I am attaching my sample here so you can try it out. It's a little hard to see the change between the comma and the decimal point, but it's definitely working correctly.
The code you posted here is just passing in the current culture - which essentially does nothing, since that's the default. So I'm a little confused about what's not working or what the problem is.
So I'm a little fuzzy on exactly what is "not working" for you.
That makes sense. If you went into you regional settings and explicitly changed the thousands separator or the digit separator, it would use whatever your machine defines. :)
Thanks Mike for the sample. It turns out it may be related to my laptops regional settings. A couple of the other developers are seeing the information fine with the formatting. I am going to close this issue and move on.