Hi Friends,How do I display a value of -77 as (77) and -77.78 as (77.78) in the UltraGrid cell?. When the user enters a negative value in the cell,he should be able to enter it, but when he removes focus from thecell, it should be displayed as a positive value wrapped with brackets.Also, this needs to be done particular cells. So it has to be at the celllevel.I tried various options but it is getting too difficult to figure this out.Kindly help,Sid.
Hi Sid,
The way the Format property of a column works is that the grid simply takes the Value of the cell and calls the ToString method and passes in the format. So the formatting is really done by the DotNet framework. As such, in order to find out more about the possible formats, you need to check out the Microsoft documentation on numeric formatting.
Here's a couple of links that should help you out.
Custom Numeric Format Strings
Standard Numeric Format Strings
Hi Mike,I will surely check that out.But then I need to bind that display format with the cell. Am I right ? If yes, then how do I bind the display format with the cell ??Regards,Sid.
You don't need a DataFilter for this, you can do it using the custom numeric formats.
All you have to do is set the Format property on the column to something like:
"#,##0.00;(#,##0.00);Zero"
Hi Mike,But that would apply to the whole column right ?I need it for only a few cells in the columns. I have identified the cells, so I would need to do it at the cell level.....Regards,Sid.
Hi Mike/Brian,Please fnd the code and screenshot in the attachments.The brackets seem to be wrapped around the -ve values but when the cell loses focus the brackets STILLremain. For instance -45.26 becomes (45.26).But, when the cell comes back in the edit mode, it should again become -45.26.Also it seems to happen for all the columns if I apply this formatting only for a single column. The screen shot willhelp.Regards,Sid.
I was mistaken when I stated that there are no .NET formats for accounting style depiction of negative values; my humble apologies for misinforming you.
The EditorDataFilterConvertArgs class exposes a 'Context' property which in this scenario is an UltraGridCell, so you would be able to apply the formatting on a per-cell basis if you wanted. There does not, however, appear to be a way to restrict the formatting to cells that are not in edit mode.