Displaying negative values in a DataGridView object using .DefaultCellStyle.Format

Greetings Experts,

I have a DataGridView object on my form that is linked to a dataTable populated based on a variable SQL query.  I use the DefaultCellStyle.Format and Alignment properties based on the datatype of the column to adjust the display style for the end user.  


DataGridView1.Columns.Item("InvoiceAmt").Width = 90
DataGridView1.Columns.Item("InvoiceAmt").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
DataGridView1.Columns.Item("InvoiceAmt").DefaultCellStyle.Format = "c" 'currency


My problem comes with the way that negative values are displayed with the .DefaultCellStyle.Format value set to "c" for currency.  For some reason, it places negative values within parenthesis, i.e. ($2250.45) instead of -$2250.45

Is there a way I can fix this to properly display the information?  Any suggestions and help are appreciated.  Thank you in advance.

LVL 2
gwosgoodIT MgrAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lazyberezovskyCommented:
This is because of default en-Us NumberFormatInfo.
http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx

Assign number format info to column:
Dim nfi As New NumberFormatInfo
nfi.CurrencySymbol = Application.CurrentCulture.NumberFormat.CurrencySymbol
nfi.CurrencyNegativePattern = 1
DataGridView1.Columns("InvoiceAmt").DefaultCellStyle.FormatProvider = nfi
DataGridView1.Columns("InvoiceAmt").DefaultCellStyle.Format = "C"

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gwosgoodIT MgrAuthor Commented:
I accept the solution because it does exactly what I asked for, but I really have no idea why.  Ill need to do a bit more research before I can fully understand the solution.

I appreciate your quick response, thank you very much.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.