0

I have a numericupdown object dynamically created inside a class, however when I enter the value manually and click on another dynamic button within the same class(or take the focus away from the numericupdown) the value keeps getting multiplied by 10 for some reason. Now I can probably get around this by constantly dividing it by 10 but I have no idea why it does this. I have the declaration like this:

amount = new NumericUpDown
        {
            Location = new Point(530, shift),
            Width = 85,
            Height = 24,
            Minimum = 0.0M,
            DecimalPlaces = 1,
            Increment = 0.1M,
            Maximum = 3500,

        };

How can I resolve this issue?

  • Do you subscribe to some events of this control? What is inside event handlers? Otherwise - what value you enter and what it become precisely? – Sinatr Mar 08 '19 at 09:56
  • I have no events assigned as of yet. I feel like the values I enter such as 63.7 or 95.3 is somehow considered invalid. – user5688333 Mar 08 '19 at 10:01
  • 1
    Could be a decimal point issue. – Sinatr Mar 08 '19 at 10:03
  • It sure looks like it, the multiplication depends of the number of decimalplaces I declare. So when I input 2 decimals like 73.77 it multiplies by 100, but that doesn't help at all – user5688333 Mar 08 '19 at 10:05
  • What is your locale? – Steve Mar 08 '19 at 10:06
  • Sounds like a culture/localization issue. Check the values of `CultureInfo.CurrentCulture.Name` and `CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator`. – kalimag Mar 08 '19 at 10:07
  • There is a [workaround](https://stackoverflow.com/a/24311556/1997232) to accept both dot and comma as decimal separator. – Sinatr Mar 08 '19 at 10:08
  • If your locale setting expect the decimal point represented by a comma but you insert 1 point 1 then when the updown looses focus the input becomes 11 – Steve Mar 08 '19 at 10:08
  • Thank you all for your prompt answers, it appears Turkish culture doesn't accept dots as seperators, I will now try the workaround – user5688333 Mar 08 '19 at 10:13
  • The issuue is now resolved with the workaround Sinatr kindly provided. Thanks again. – user5688333 Mar 08 '19 at 10:22

0 Answers0