Share via


How to: Set the Format for the Windows Forms NumericUpDown Control

You can configure how values are displayed in the Windows Forms NumericUpDown control. The DecimalPlaces property determines how many numbers appear after the decimal point; the default is 0. The ThousandsSeparator property determines whether a separator will be inserted between every three decimal digits; the default is false. The control can display values in hexadecimal instead of decimal format, if the Hexadecimal property is set to true; the default is false.

To format the numeric value

  • Display a decimal value by setting the DecimalPlaces property to an integer and setting the ThousandsSeparator property to true or false.

    NumericUpDown1.DecimalPlaces = 2
    NumericUpDown1.ThousandsSeparator = True
    
    numericUpDown1.DecimalPlaces = 2;
    numericUpDown1.ThousandsSeparator = true;
    
    numericUpDown1.set_DecimalPlaces(2);
    numericUpDown1.set_ThousandsSeparator(true);
    
    numericUpDown1->DecimalPlaces = 2;
    numericUpDown1->ThousandsSeparator = true;
    

    -or-

  • Display a hexadecimal value by setting the Hexadecimal property to true.

    NumericUpDown1.Hexadecimal = True
    
    numericUpDown1.Hexadecimal = true;
    
    numericUpDown1.set_Hexadecimal(true);
    
    numericUpDown1->Hexadecimal = true;
    
    NoteNote

    Even if the value is displayed on the form as hexadecimal, any tests you perform on the Value property will be testing its decimal value.

See Also

Reference

NumericUpDown Control Overview (Windows Forms)
NumericUpDown Class

Other Resources

NumericUpDown Control (Windows Forms)