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. Advertising

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:
    7,551
    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=
    Oct 19, 2004
  2. Replies:
    7
    Views:
    9,217
    Jeff Dillon
    May 17, 2006
  3. Memana
    Replies:
    1
    Views:
    320
    Alf P. Steinbach
    Jul 5, 2004
  4. Christopher Benson-Manica

    Empty parentheses

    Christopher Benson-Manica, Oct 17, 2003, in forum: C Programming
    Replies:
    10
    Views:
    601
    Jeremy Yallop
    Oct 17, 2003
  5. Replies:
    44
    Views:
    938
    Timo Virkkala
    Jan 6, 2005
Loading...

Share This Page