您可以設定值在 Windows Forms NumericUpDown 控制項中的顯示方式。 DecimalPlaces 屬性可決定小數點後出現多少個數字;預設值為 0。 ThousandsSeparator 屬性可決定是否在每三位小數之間插入分隔符號;預設為 false。 如果 Hexadecimal 屬性設定為 true,則控制項可以以十六進位而非十進位格式顯示值;預設為 false。
若要格式化數值
將 DecimalPlaces 屬性設定為整數並將 ThousandsSeparator 屬性設定為
true或false,以顯示十進位值。NumericUpDown1.DecimalPlaces = 2 NumericUpDown1.ThousandsSeparator = TruenumericUpDown1.DecimalPlaces = 2; numericUpDown1.ThousandsSeparator = true;numericUpDown1->DecimalPlaces = 2; numericUpDown1->ThousandsSeparator = true;-或-
將 Hexadecimal 屬性設定為
true,以顯示十六進位值。NumericUpDown1.Hexadecimal = TruenumericUpDown1.Hexadecimal = true;numericUpDown1->Hexadecimal = true;備註
即使該值在表單上顯示為十六進位,您對 Value 屬性執行的任何測試也都會測試其十進位值。