简体   繁体   中英

Winforms TextBox number presentation

I want the TextBox to display numbers with 3 digits and exponentials.

fe 0.123E-08

Is there a Way to do this with normal Winforms TextBoxes?

As I now there is not a native property on Textbox but you can apply the instructions on the links below.

http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx

http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx#EFormatString

You can use double.ToString() to format the string before setting TextBox.Text .

For example:

double value = 0.00000000123;

string s = value.ToString("#.###E00");
Console.WriteLine(s);

Or just assign to TextBox.Text:

textBox.Text = value.ToString("#.###E00");;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM