DeniseGoodheart
asked on
How to Format DataGridView Cell
Good Day:
I am creating a WinForms application using VS.NET 2005, VB.NET, and the DataGridView control. The Unit Price cell on my DataGridView control rounds my number and I do not want the numbers to be rounded. For example, .375 gets rounded to .38. How do I format so it does not round the number? My format code is as follows:
grdDetail.Columns("Unit Price").DefaultCellStyle.F ormat = "#,###,###.00"
Any Suggestions?
Thank You,
Denise
I am creating a WinForms application using VS.NET 2005, VB.NET, and the DataGridView control. The Unit Price cell on my DataGridView control rounds my number and I do not want the numbers to be rounded. For example, .375 gets rounded to .38. How do I format so it does not round the number? My format code is as follows:
grdDetail.Columns("Unit Price").DefaultCellStyle.F
Any Suggestions?
Thank You,
Denise
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hello,
I figured it out. I simply added an extra 0 at the end as follows:
Me.grdDetail.Columns("Unit Price").DefaultCellStyle.F ormat = "#,###,###.000"
Cheers,
Denise
I figured it out. I simply added an extra 0 at the end as follows:
Me.grdDetail.Columns("Unit
Cheers,
Denise
That's no prob. Apologies, i assumed you wanted the value to two decimal places without rounding up.
For any reference to existing standard or custom numeric format specifiers. Just check out:
http://msdn.microsoft.com/en-us/library/427bttx3.aspx
For any reference to existing standard or custom numeric format specifiers. Just check out:
http://msdn.microsoft.com/en-us/library/427bttx3.aspx
ASKER
Thank you for posting your code. I was hoping for a simple format code. There has to be an easier way.