アップダウン コントロールに表示する最大値を取得または設定します。
Public Property Maximum As Decimal
[C#]
public decimal Maximum {get; set;}
[C++]
public: __property Decimal get_Maximum();public: __property void set_Maximum(Decimal);
[JScript]
public function get Maximum() : Decimal;public function set Maximum(Decimal);
プロパティ値
アップダウン コントロールに表示する最大値。既定値は、100 です。
解説
Maximum プロパティが設定されている場合は、 Minimum プロパティが評価され、 UpdateEditText メソッドが呼び出されます。 Minimum プロパティが、 Maximum プロパティに新しく設定した値よりも大きくなってしまう場合は、 Minimum プロパティの値が Maximum プロパティの値に等しく設定されます。現在の Value プロパティが、 Maximum プロパティに新しく設定した値よりも大きくなってしまう場合は、 Value プロパティの値が Maximum プロパティの値に等しく設定されます。
使用例
NumericUpDown コントロールを作成および初期化し、一部の共通プロパティを設定し、これらのプロパティ値をユーザーが実行時に変更できるようにする例を次に示します。このコードは、フォーム上に 3 つの CheckBox コントロールが配置されていること、それらのコントロールの Click イベントのハンドラがインスタンス化されていることを前提にしています。 DecimalPlaces プロパティ、 ThousandsSeparator プロパティ、および Hexadecimal プロパティは、各チェック ボックスの Click イベント時に設定されます。
Public Sub InstantiateMyNumericUpDown()
' Create and initialize a NumericUpDown control.
numericUpDown1 = New 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)
End Sub
' Check box to toggle decimal places to be displayed.
Private Sub checkBox1_Click(sender As Object, e As EventArgs)
' 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 Then
numericUpDown1.DecimalPlaces = 0
numericUpDown1.Value = Decimal.Round(numericUpDown1.Value, 0)
Else
numericUpDown1.DecimalPlaces = 2
numericUpDown1.Increment = 0.25D
End If
End Sub
' Check box to toggle thousands separators to be displayed.
Private Sub checkBox2_Click(sender As Object, e As EventArgs)
' If ThousandsSeparator is true, set it to false;
' otherwise, set it to true.
If numericUpDown1.ThousandsSeparator Then
numericUpDown1.ThousandsSeparator = False
Else
numericUpDown1.ThousandsSeparator = True
End If
End Sub
' Check box to toggle hexadecimal to be displayed.
Private Sub checkBox3_Click(sender As Object, e As EventArgs)
' If Hexadecimal is true, set it to false;
' otherwise, set it to true.
If numericUpDown1.Hexadecimal Then
numericUpDown1.Hexadecimal = False
Else
numericUpDown1.Hexadecimal = True
End If
End Sub
[C#]
public void InstantiateMyNumericUpDown()
{
// Create and initialize a NumericUpDown control.
numericUpDown1 = new 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);
}
// Check box to toggle decimal places to be displayed.
private 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 = 0.25M;
}
}
// Check box to toggle thousands separators to be displayed.
private 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.
private 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;
}
}
[C++]
public:
void InstantiateMyNumericUpDown() {
// Create and initialize a NumericUpDown control.
numericUpDown1 = new 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);
};
// Check box to toggle decimal places to be displayed.
private:
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 = 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;
}
};
[JScript]
function InstantiateMyNumericUpDown(){
// Create and initialize a NumericUpDown control.
numericUpDown1 = new 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)
}
// Check box to toggle decimal places to be displayed.
function checkBox1_Click(sender : Object, e : EventArgs){
// 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 = 0.25
}
}
// Check box to toggle thousands separators to be displayed.
function checkBox2_Click(sender : Object, e : EventArgs){
// If ThousandsSeparator is true, set it to false;
// otherwise, set it to true.
numericUpDown1.ThousandsSeparator = !numericUpDown1.ThousandsSeparator
}
// Check box to toggle hexadecimal to be displayed.
function checkBox3_Click(sender : Object, e : EventArgs){
// If Hexadecimal is true, set it to false;
// otherwise, set it to true.
numericUpDown1.Hexadecimal = !numericUpDown1.Hexadecimal
}
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET
参照
NumericUpDown クラス | NumericUpDown メンバ | System.Windows.Forms 名前空間 | Increment | Minimum | UpdateEditText