format numbers with parentheses

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rob

    #1

    format numbers with parentheses

    Hi all,

    I want to format right-aligned positive and negative numbers in a grid. My
    problem is that I want the negs in parentheses, which is throwing out the
    alignment.

    For example, using the format string "#,###.00;(#,## #.00)":
    123.45
    (678.90)

    Notice how (when viewed with a fixed width font) the close bracket on the
    negative number pushes the string to the left by one char and is therefor
    throwing the alignment off.

    In Excel one can cater for this by using the underscore, followed by the
    char you want to allow space for, so my format string would look like this:
    "#,###.00_);(#, ###.00)"

    This would mean that positive numbers would have the pixels normally
    allocated to a right parentheses after them, and positive and negative
    numbers would line up perfectly. But .Net doesn't seem to support this
    trick.

    How do I align such numbers in .Net?


    Thanks,



    Rob



Working...