Export (0) Print
Expand All

Setting the Format for the Windows Forms NumericUpDown Control

Visual Studio .NET 2003

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 zero. 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.
    ' Visual Basic
    NumericUpDown1.DecimalPlaces = 2
    NumericUpDown1.ThousandsSeparator = True
    
    // C#
    numericUpDown1.DecimalPlaces = 2;
    numericUpDown1.ThousandsSeparator = true;
    
    // C++
    numericUpDown1->DecimalPlaces = 2;
    numericUpDown1->ThousandsSeparator = true;
    

    -or-

  • Display a hexadecimal value by setting the Hexadecimal property to true.
    ' Visual Basic
    NumericUpDown1.Hexadecimal = True
    
    // C#
    numericUpDown1.Hexadecimal = true;
    
    // C++
    numericUpDown1->Hexadecimal = true;
    
    Note   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

NumericUpDown Control (Windows Forms) | Introduction to the Windows Forms NumericUpDown Control | NumericUpDown Class

Show:
© 2014 Microsoft