Link to home
Start Free TrialLog in
Avatar of gwosgood
gwosgoodFlag for United States of America

asked on

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.

ASKER CERTIFIED SOLUTION
Avatar of lazyberezovsky
lazyberezovsky
Flag of Belarus image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gwosgood

ASKER

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.