Open
Conversation
…+2212) - Updated OnPreviewTextInput to convert ASCII '-' to culture's actual negative sign before validation - Updated TryGetNumberFromText regex to include culture-specific negative and positive signs - Updated ValidateText to normalise culture-specific signs to ASCII before double.TryParse
Remove of accidental lines at the end
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixed an issue where the NumericUpDown control did not support keyboard entry of culture-specific negative signs. Cultures such as Norwegian (nb-NO) use U+2212 (−) as their negative sign rather than the standard ASCII hyphen-minus (-). This caused any attempt to enter a negative number via keyboard or paste to be blocked or lost.
Three changes were made to NumericUpDown.cs:
Unit test
A unit test should verify that a NumericUpDown configured with Norwegian culture (nb-NO) correctly accepts U+2212 (−) as a negative sign both via keyboard entry and paste, and that the resulting value is correctly parsed and stored as a negative number.
Additional context
This issue affects any culture where CultureInfo.NumberFormat.NegativeSign is not the standard ASCII hyphen-minus (-), including but not limited to Norwegian (nb-NO). The fix is culture-agnostic and will correctly handle any culture's negative and positive sign characters.
Closes Issue #4560