format numbers with parentheses

R

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top