473,320 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

format numbers with parentheses

Rob
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

Jul 21 '05 #1
0 1346

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Rowan Chapman | last post by:
Hey all! I'm kinda new to VB but not to programin'. So I know what it is like when you are asked trivial questions. Could some1 please tell me what the syntax would be 2 only allow numerical data...
19
by: Moritz Beller | last post by:
Dear programmers, Have a look at this function to generate random numbers from 1 to count. It simply does not work. Well, actually it compiles silently, but then returns "1" (Compiler: gcc/++...
5
by: Ataru Morooka | last post by:
Hi, my table has to have a column with the months names (january, february...). When I order it by month it is ordered alphabetically and that's not what I need. Reading this ng I found someone...
5
by: Subrahmanyam Arya | last post by:
Hi Folks , I am trying to solve the problem of reading the numbers correctly from a serial line into an intel pentium processor machine . I am reading 1 byte and 2byte data both positive...
5
by: Fabian | last post by:
I am making a winforms-program in Visual Studio, that connects to an Access database. In the database all dates are presented in this format : dd-mm-yyyy. In my application I have a DatetimePicker,...
0
by: Rob | last post by:
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...
2
by: Joe | last post by:
Is there a format string to auto convert negative numbers to display in parentheses? For example myInt.ToString("if < 0 (#) else #"). I need to pass a format to another control so I can't check...
7
by: Aek | last post by:
Hi everyone, I am trying to construct a regular expression and format string to use with a boost::regex_replace() In my file the sample text is: // .fx shader file FLOAT JOE 3545f; FLOAT...
6
by: psbasha | last post by:
I have a input format XX:YY:ZZ and the start value may be 'n' digit numbers for X,Y,Z. So I have to assign the numbers based on the above format ( Format may change) Say Example - 1 ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.