String formatting

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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.
 
Back
Top