Formatting Conversion from Double to String...
For example:
double
textBox1->Text = System::Convert::ToString(x);
Any suggestions?
This method will display "100" in the textbox but I would like it to display "100.00" in the textbox.
For example:
double
textBox1->Text = System::Convert::ToString(x);
Any suggestions?
This method will display "100" in the textbox but I would like it to display "100.00" in the textbox.
textBox1->Text = String::Format("{0:N}", x);
Note that the above line will also append thousand separators for large numbers (eg. 1,000,000). Please take a look at the link for further information about the String::Format method.
OK, I found it with your help. Instead of
"{0:N}", x
I use
"{0:F4}", x
that gives me a decimal precision of 4.
But my next question is how do you make the precision dynamic so that it can be chosen at run time?
Something like this:
MyFormat = "{0:F" + int(myPrec).ToString() + "}";