c# - Handle 2 types of number format using culture if possible -


currently i've following scenario :

i've custom control numeric input. have property called : decimaltype. might long or short decimal.

and, problem : want format given input common. either format current input in 2 decimal digits (short) or 4 decimal digits(long) using current culture.

i can setup 1 format on current culture.

thread.currentthread.currentculture.numberformat.numberdecimaldigits = 2; 

or

thread.currentthread.currentculture.numberformat.numberdecimaldigits = 4; 

so, in situation, how handle efficiently? because, in single form there might 2 short decimal textboxes , 4 long decimal textboxes. changing numberdecimaldigits 2 not work long decimal or vice-versa.

in short : text should formatted according current culture 2 custom decimal length.

any suggestions can follow handle things?

there 2 options here. (1) use explicit custom number format pattern number of decimal digits -- #,0.00 , #,0.0000 -- or (2) don't rely on currentculture @ all. formatting functions allow explicitly provide cultureinfo object can have 1 each.

personally, use option 1.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -