01-12-2012 04:33 PM
Hi,
I want to customize a datagrid column such that if the value if positive number, it should as 333,333, if it is negative, then show as (333,333).
What is the best way to do it?
Thanks a lot
01-13-2012 07:20 AM
I actually don't know how to put () around a negative number.....remember this is Delphi based code on the LAN side of things.....
http://www.delphibasics.co.uk/RTL.asp?Name=Format
%m12.2 for money for example.....
The format string is placed IN the column's FormatString property.
02-14-2012 12:14 PM - edited 02-14-2012 12:15 PM
You could make the column a Text column and format the value before it enters the grid. If you are manually setting the SQL property you might be able to pass this though the provider
Case WHEN {field} <0 then '(' + convert(varchar(100),abs({field})) +')' Else {field} END as {field}
The example would be
“Select Product, Case WHEN Price <0 then '(' + convert(varchar(100),abs(Price)) +')' Else Price END as Price From product”
Another option is to make a SQL computed Columns http://msdn.microsoft.com/en-us/library/ms191250.aspx. This will allow you to make a column on the table that is formatted like you want. The plus side of the SQL column is that it can be added to groups, and reusing it is much simpler. The downside of the computed column is that we had had problems using them on remote DBs.