format numbers with parentheses

Discussion in 'ASP .Net Datagrid Control' started by Rob, Nov 4, 2003.

  1. Rob

    Rob Guest

    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 "#,###.##;(#,###.##)":
    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:
    "#,###.##_);(#,###.##)"

    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
     
    Rob, Nov 4, 2003
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UGF0cmljay5PLklnZQ==?=

    'AddressOf' operand must be the name of a method; no parentheses a

    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=, Oct 18, 2004, in forum: ASP .Net
    Replies:
    15
    Views:
    8,324
    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=
    Oct 19, 2004
  2. Subra
    Replies:
    25
    Views:
    1,615
    user923005
    Mar 8, 2007
  3. Andrew Tatum

    Fibonacci Numbers and Lucas Numbers

    Andrew Tatum, May 26, 2007, in forum: C++
    Replies:
    6
    Views:
    851
    Howard
    May 27, 2007
  4. Lance Hoffmeyer
    Replies:
    2
    Views:
    764
    Lance Hoffmeyer
    Jul 26, 2007
  5. jko170
    Replies:
    9
    Views:
    355
    jko170
    Jan 21, 2009
  6. GIMME
    Replies:
    5
    Views:
    449
    Thomas 'PointedEars' Lahn
    Jul 26, 2004
  7. D'Anne Asquith

    Numbers not acting like numbers

    D'Anne Asquith, Oct 1, 2003, in forum: Perl Misc
    Replies:
    2
    Views:
    277
    Heinrich Mislik
    Oct 2, 2003
  8. one man army

    Numbers to strings to numbers again

    one man army, Dec 28, 2005, in forum: Javascript
    Replies:
    6
    Views:
    336
    one man army
    Dec 30, 2005
Loading...