NumericUpDown: accept both comma and dot as decimal separator

T30

There's a way to force c# NumericUpDown to accept both comma and dot, to separate decimal values?

I've customized a textbox to do it (practically replacing dots with commas), but I'm surprised that there isn't another way..

This question explains how to change the separator, but I would like to use both!

Nicolas R

NumericUpDown control uses the culture of the operating system to use comma or dots as a decimal separator.

If you want to be able to handle both separators and consider them as a decimal separator (ie: not a thousand separator), you can use Validation or manual event treatment, for example:

private void numericUpDown1_KeyPress(object sender, KeyPressEventArgs e)
    {
        if (e.KeyChar.Equals('.') || e.KeyChar.Equals(','))
        {
            e.KeyChar = ((System.Globalization.CultureInfo)System.Globalization.CultureInfo.CurrentCulture).NumberFormat.NumberDecimalSeparator.ToCharArray()[0];
        }
    }

In this example you will replace every dot and comma by the NumericDecimalSeparator of the current culture

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

NumericUpDown: accept both comma and dot as decimal separator

From Dev

How to accept both dot and comma as a decimal separator with WTForms?

From Dev

JavaScript regex to accept numbers with comma separator (thousands) and dot separator (decimals)

From Dev

How to convert floating point decimal separator from dot to comma in Javascript

From Dev

How to change the decimal separator from a comma to a dot in SQL Server

From Dev

Decimal dot and thousands separator used both in input type number

From Dev

dot instead of comma as thousand separator

From Dev

Masked EditText with comma as decimal separator

From Dev

seq uses comma as decimal separator

From Dev

Format a decimal with comma as decimal separator and without thousands separator

From Dev

Convert a number and accept any decimal separator

From Dev

Jaxb conversion of number with comma as a decimal separator

From Dev

Why django uses a comma as decimal separator

From Dev

How to make InvariantCulture recognize a comma as a decimal separator?

From Dev

Show comma instead of point as decimal separator

From Dev

Convert a double to 2 decimal places with comma separator

From Dev

Read txt file with comma decimal separator in MATLAB

From Dev

Parsing numbers with a comma decimal separator in JavaScript

From Dev

Only add thousand separator before decimal comma

From Dev

Convert a double to 2 decimal places with comma separator

From Dev

Show comma instead of point as decimal separator

From Dev

Read txt file with comma decimal separator in MATLAB

From Dev

bc: decimal separator comma vs. point

From Dev

Add comma separator to a numbers with 2 decimal points

From Dev

Google form regex for numbers with comma as decimal separator

From Dev

Can i use both a comma and a dot?

From Dev

AngularJS decimal input: change comma to dot

From Dev

Difference between decimal number with comma and dot Javascript

From Dev

Allow dot and comma in numbers, not only for decimal

Related Related

  1. 1

    NumericUpDown: accept both comma and dot as decimal separator

  2. 2

    How to accept both dot and comma as a decimal separator with WTForms?

  3. 3

    JavaScript regex to accept numbers with comma separator (thousands) and dot separator (decimals)

  4. 4

    How to convert floating point decimal separator from dot to comma in Javascript

  5. 5

    How to change the decimal separator from a comma to a dot in SQL Server

  6. 6

    Decimal dot and thousands separator used both in input type number

  7. 7

    dot instead of comma as thousand separator

  8. 8

    Masked EditText with comma as decimal separator

  9. 9

    seq uses comma as decimal separator

  10. 10

    Format a decimal with comma as decimal separator and without thousands separator

  11. 11

    Convert a number and accept any decimal separator

  12. 12

    Jaxb conversion of number with comma as a decimal separator

  13. 13

    Why django uses a comma as decimal separator

  14. 14

    How to make InvariantCulture recognize a comma as a decimal separator?

  15. 15

    Show comma instead of point as decimal separator

  16. 16

    Convert a double to 2 decimal places with comma separator

  17. 17

    Read txt file with comma decimal separator in MATLAB

  18. 18

    Parsing numbers with a comma decimal separator in JavaScript

  19. 19

    Only add thousand separator before decimal comma

  20. 20

    Convert a double to 2 decimal places with comma separator

  21. 21

    Show comma instead of point as decimal separator

  22. 22

    Read txt file with comma decimal separator in MATLAB

  23. 23

    bc: decimal separator comma vs. point

  24. 24

    Add comma separator to a numbers with 2 decimal points

  25. 25

    Google form regex for numbers with comma as decimal separator

  26. 26

    Can i use both a comma and a dot?

  27. 27

    AngularJS decimal input: change comma to dot

  28. 28

    Difference between decimal number with comma and dot Javascript

  29. 29

    Allow dot and comma in numbers, not only for decimal

HotTag

Archive