Reputation: 14973
I have in my C# WinForm DataGridView that holds numbers
the problem is that:
0.5 --> shows --> .5 and
-45 --> shows --> 45-
in my DataGridView the RightToLeft = yes (i must have this)
how I can fix it ?
Upvotes: 3
Views: 413
Reputation: 216353
Use the Format property of a DataGridViewCellStyle.
For example (supposing your first colum's name is "Value")
dataGridView1.Columns["Value"].DefaultCellStyle.Format = "0.0";
The Format property takes strings 'formats' well explained in these articles on MSDN
Custom Numeric Format Strings
Standard Numeric Format Strings
Upvotes: 2
Reputation: 1010
double value = .5;
var display = value.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture));
Upvotes: 0
Reputation: 4866
See the formatting Types & custom numeric format strings
here & here
& How to format data
in DataGridView here - http://msdn.microsoft.com/en-us/library/f9x2790s.aspx
Upvotes: 0