String formatting

G

Guest

Hi,

I would like to format the strings and align them by decimal point.

This is what I am doing and displaying them in a multiline textbox.

formatstr = "{0:###.####}";
tempStr = String.Format(formatstr, val);

This does not align them by decimal point. How can I align them by decimal point.

Thanks.
 
M

mikeb

Thomas said:
Hi,

I would like to format the strings and align them by decimal point.

This is what I am doing and displaying them in a multiline textbox.

formatstr = "{0:###.####}";
tempStr = String.Format(formatstr, val);

This does not align them by decimal point. How can I align them by decimal point.

If you don't mind trailing zeros:

formatstr = "{0,9:##0.0000}";

If you don't want trailing zeros, then I'm not sure that you can do it
with just a format string - you might need to write some code.
 

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

Top