NumericUpDown::Maximum Property
Gets or sets the maximum value for the spin box (also known as an up-down control).
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
When the Maximum property is set, the Minimum property is evaluated and the UpdateEditText method is called. If the Minimum property is greater than the new Maximum property, the Minimum property value is set equal to the Maximum value. If the current Value is greater than the new Maximum value. the Value property value is set equal to the Maximum value.
The following code example creates and initializes a NumericUpDown control, sets some of its common properties, and allows the user to change some of these properties at run time. This code assumes three CheckBox controls have been placed on a form and handlers for their Click events have been instantiated. The DecimalPlaces, ThousandsSeparator, and Hexadecimal properties are set on the Click event of each check box.
public: void InstantiateMyNumericUpDown() { // Create and initialize a NumericUpDown control. numericUpDown1 = gcnew NumericUpDown; // Dock the control to the top of the form. numericUpDown1->Dock = System::Windows::Forms::DockStyle::Top; // Set the Minimum, Maximum, and initial Value. numericUpDown1->Value = 5; numericUpDown1->Maximum = 2500; numericUpDown1->Minimum = -100; // Add the NumericUpDown to the Form. Controls->Add( numericUpDown1 ); } private: // Check box to toggle decimal places to be displayed. void checkBox1_Click( Object^ sender, EventArgs^ e ) { /* If DecimalPlaces is greater than 0, set them to 0 and round the current Value; otherwise, set DecimalPlaces to 2 and change the Increment to 0.25. */ if ( numericUpDown1->DecimalPlaces > 0 ) { numericUpDown1->DecimalPlaces = 0; numericUpDown1->Value = Decimal::Round( numericUpDown1->Value, 0 ); } else { numericUpDown1->DecimalPlaces = 2; numericUpDown1->Increment = Decimal(0.25); } } // Check box to toggle thousands separators to be displayed. void checkBox2_Click( Object^ sender, EventArgs^ e ) { /* If ThousandsSeparator is true, set it to false; otherwise, set it to true. */ if ( numericUpDown1->ThousandsSeparator ) { numericUpDown1->ThousandsSeparator = false; } else { numericUpDown1->ThousandsSeparator = true; } } // Check box to toggle hexadecimal to be displayed. void checkBox3_Click( Object^ sender, EventArgs^ e ) { /* If Hexadecimal is true, set it to false; otherwise, set it to true. */ if ( numericUpDown1->Hexadecimal ) { numericUpDown1->Hexadecimal = false; } else { numericUpDown1->Hexadecimal = true; } }
Available since 1.1