简体   繁体   中英

How can I format a number but show all digits of precision?

When a user goes to edit a number, I want to format a number to have a thousands separator in one case (and a percentage sign in another) but I want to be able to show absolutely all available digits of precision.

When the number is being displayed, its format is simply {0:0,0;-0,0; - } {0:0,0;-0,0; - } , (or {0:0,0.00;-0,0.00; - } to show two decimal places), but when my control goes into edit mode, I want to switch to displaying something very similar, but showing all available digits of precision. Is there any way to do this short of creating a format string that looks like this?

{0:0,0.#############################;-0,0.###...

I want to do something similar with percentages. I want to displayed value to be {0:0.00 %;-0.00 %; - } {0:0.00 %;-0.00 %; - } until the user activates the cell for editing, at which time the format should still be a percentage, but showing more digits of precision if they exist in the underlying value.

Thanks

This question is similar to yours. (The answer is that it's not possible with the .NET built-in custom numeric formatting.)

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