c# - TextBox with automatic culture formatting? -
I am trying to create a text box that only allows positive integer input, and it's a culture-specific formatting Should display the input automatically (in this case N-US, hence it should use the ',' symbol as the separator for large numbers). Therefore:
- An entry of 1000 in the text box should be shown as '1,000'
- An entry of 1,000 should be shown in this way, but it should be correctly ...
Currently, no automatic formatting is done in the first case, and the second case turns an error from the validation rule. Implemented that the input is correct (which uses TryParse as a standard Check if the number is entered).
I'm embarrassed to think about globalization and internationalization, so I'm wondering if there is some culture magic, I can work to isolate it.
It The code-back to the text box is xaml:
(Object value, CultureInfo cultureInfo) {UInt64 popValue; If (value == faucet) {new verification returns return (true, empty); } Else if (UINT64.TryParse (value), (value, numberStyles.AllowThousands, Null, popValue out)) {Return New ValidationResult (incorrect, "Value should be valid number."); } New Validation Return Return (True, Empty); }}
In a different form, I want the text box, to be able to display them blank - Now, the text box displays '0' on load , And leaving the text box empty, one runs validation error (though I allow it in validation rule). As far as I can assemble, when I force the text box to give a numerical value, then it does not have zero value allowed. Is there some way to handle that as well?
Text after "div class =" itemprop = "text">
You can find useful, pay attention to the CultureInfo class
Good explanation ..
Comments
Post a Comment