NumericUpDown StringFormat doesn't handle percentages correctly.
See original GitHub issueThere’s strange behaviour happening with NumericUpDown
’s StringFormat
property, particularly around percentages.
First it looks like the P
, %
& ‰
format specifiers are being ignored, but when adding those same symbols outside of a format item, the numbers appear to be divided by 100 or 1000.
I do remember more frustrating issues before however - particularly with editing values. Previously, the numbers would look correct initially. After editing, the real value would be multiplied repeatedly.
To Reproduce:
Case 1:
- Set
NumericUpDown.StringFormat
to{0:0.00%}
or0.00%
- Set
NumericUpDown.Value
to0.25
- See that the label now shows
0.25%
(expected25.00%
)
Case 2:
- Set
NumericUpDown.StringFormat
to{0:0.00‰}
or0.00‰
- Set
NumericUpDown.Value
to0.25
- See that the label now shows
0.25‰
(expected250.00%
)
Case 3:
- Set
NumericUpDown.StringFormat
to{0:0.0000}%
- Set
NumericUpDown.Value
to0.25
- See that the label now shows
0.0025%
(expected0.2500%
) - Additionally, editing this number causes further division to the real value.
Case 4:
- Set
NumericUpDown.StringFormat
to{0:0.00000}‰
- Set
NumericUpDown.Value
to0.25
- See that the label now shows
0.00025‰
(expected0.25000‰
) - Additionally, editing this number causes further division to the real value.
Case 5:
- Set
NumericUpDown.StringFormat
toP
- Set
NumericUpDown.Value
to0.25
- See that the label now shows
0.25%
(expected25.00 %
)
Environment:
- MahApps.Metro version 2.0.0-alpha0083
- OS: Win10 1803
- Visual Studio 2017 15.7.1
- .NET Framework 4.6.2
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:11 (7 by maintainers)
Top Results From Across the Web
NumericUpDown control for Percentages?
A quick and easy answer to this question: use DecimalUpDown from the Extended WPF Toolkit, instead of NumericUpDown (it should be noted that...
Read more >NumericUpDown - ValueFormat as Pecentage
Hi,I have trouble when trying use the NumericUpDown control with the following configuration:ValueFormat = ValueFormat.Percentage ...
Read more >Thread: Format String Textbox
To start with the % sign should never be part of the value assessed. You should actually be doing the complete opposite of...
Read more >MahApps.Metro v2.0.0 release notes (2020-05-24) | LibHunt
... SnapToMultipleOfInterval property does not work with decimal increments; #3376 NumericUpDown StringFormat doesn't handle percentages correctly.
Read more >Set the Format for NumericUpDown Control
Learn how to set the format for the Windows Forms NumericUpDown control, by means of code samples in Visual Basic, C#, and CPP....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@mgnslndh @timunie The same with ‰