(First of all: this is not a duplicate of Format numbers with floating points and sign in textbox in C#)
I am using the solution from dodald (https://stackoverflow.com/a/27510646/3179989) for formatting numbers with floating points and sign to make them aligned based on the floating point:
textbox1.Text = String.Format("{0:+;-}{0,9:0.00000;0.00000}", number1);
textbox2.Text = String.Format("{0:+;-}{0,9:0.00000;0.00000}", number2);
textbox3.Text = String.Format("{0:+;-}{0,9:0.00000;0.00000}", number3);
textbox4.Text = String.Format("{0:+;-}{0,9:0.00000;0.00000}", number4);
textbox5.Text = String.Format("{0:+;-}{0,9:0.00000;0.00000}", number5);
It works perfectly for numbers are like -1.23456 (results in "- 1.23456"), however if the number is 1.2, then this will change it to "+ 1.20000".
Questions: Is there anyway to avoid any extra zeros? How can I add a space at the end of the text by using the formatting parameters and not using (text + " ")?
Thanks in advance
EDIT: to clarify this here is what I am looking for:
-123.123456
+ 1.123456
- 0.123456
- 0.123
+ 1.1
- 12.123456
I have multiple textboxes that are vertically aligned. I want the numbers to be displayed the way is presented above where the position of the floating point is always fixed and vertically aligned. The solution provided by dodald (https://stackoverflow.com/a/27510646/3179989) works just for the number with five decimal numbers like -1.23456 (results in "- 1.23456"), however if the number is 1.2, then his solution will change it to "+ 1.20000". I'd like to remove the added zeros to the string.