NumericUpDown Exponent displayed for decimal type
See original GitHub issueWhen binding a decimal? to the value of a NumericUpDown control it still formats the value like a double with showing the exponent like 5E-05 instead of 0,00005.
Doesn’t the NumericUpDown Control just use the ToString method of the value Property? Like in the example below a decimal ToString print the value with zeros not with exponent.
(0.00005).ToString() // 5E-05
((decimal)(0.00005)).ToString() // 0,00005
At the moment i made a workaround setting the StringFormat of the NumericUpDown controls
<Style BasedOn="{StaticResource {x:Type mah:NumericUpDown}}" TargetType="{x:Type mah:NumericUpDown}">
<Setter Property="StringFormat" Value="0.##########################" />
</Style>
But i was woundering why the NumericUpDown control behave like that. Will the value internal be converted to a double?
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
c# - .NET NumericUpDown with Decimals=AsNeeded
Simply set the number of decimal places shown by the NumericUpDown control as needed: Private Sub NumericUpDown1_ValueChanged(sender As ...
Read more >NumericUpDown does not round to enforce DecimalPlaces
NumericUpDown would internally round to zero decimal places, using something like Math.Round(), and Value would be 2 like it shows in the text ......
Read more >How to set the Decimal Places in the NumericUpDown ...
Int32 types, which represents the number of decimal places to display in the up-down control. It will throw an ArgumentOutOfRangeException ...
Read more >NumericUpDown.DecimalPlaces Property
Gets or sets the number of decimal places to display in the spin box (also known as an up-down control). This property doesn't...
Read more >Controlling input in Numeric Updown
For example, if the NUD is displaying two decimal places for currency, different people might want to set the Increment to 1 for...
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
Hi @Kabennsky at the Moment the value is converted into a
double
, also if you bind to adecimal
. I had a short discussion with @punker76 and he explained that we cannot change the value todecimal
and it will cover all types, because they have different min, max and precision: https://exceptionnotfound.net/decimal-vs-double-and-other-tips-about-number-types-in-net/one idea was to add an enum where the user can choose the type of the value. The default would be
double
. At the moment this is just an idea, so will see if he gets it to work or not.Happy coding Tim
Is it possible to support decimal/nullable decimal so that there is no conversion to/from other numeric types?