Reputation: 8462
I'm using infragistic grid, and setting DisplayFormat of each column. DisplayFormat is type of string, and uses it`s value to show value of cellValue.ToString(DisplayFormat), when showing values to user in a grid (as Infra docs saying)
In grid I have doubles, that have many numbers after point, and I don`t know how many. And I need to use thousand seperator. So:
If I have:
<br/>
12345678.12345
<br/>
12345678.12
<br/>
, I want grid to show:
<br/>
1234,5678.12345
<br/>1234,5678.12
If I set DisplayFormat to N5, I get: 1234,5678.12000
How can I do that?
Upvotes: 0
Views: 495
Reputation: 879
try this
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-us");
double x = 1234567.2342342d;
Console.WriteLine(string.Format("{0:0,0.00}", x));
output:
1,234,567.23
Upvotes: 0
Reputation: 2340
I suggest using N2. The number is the amount of decimals you wish to see, padding it with zeroes, if necessery.
Upvotes: 0
Reputation: 269388
It's not really clear to me what you want.
N2
.#,0.##
.#,0.########
. (Ideally you'd have about 340 #
characters after the decimal point to handle all possible miniscule double
values. It's up to you to determine exactly what you need.)Upvotes: 3