방법: Windows Forms NumericUpDown 컨트롤을 사용하여 숫자 값 설정 및 반환
Windows Forms NumericUpDown 컨트롤의 숫자 값은 이 컨트롤의 Value 속성에 의해 결정됩니다. 다른 속성과 마찬가지로 컨트롤 값에 대한 조건부 테스트를 작성할 수 있습니다. Value 속성이 설정되면 이 속성에 대해 작업을 수행하는 코드를 작성하여 직접 값을 조정하거나 UpButton 및 DownButton 메서드를 호출할 수 있습니다.
숫자 값을 설정하려면
코드 또는 속성 창에서 Value 속성에 값을 할당합니다.
NumericUpDown1.Value = 55
numericUpDown1.Value = 55;
numericUpDown1.set_Value(new Decimal(55));
numericUpDown1->Value = 55;
또는
UpButton 또는 DownButton 메서드를 호출하여 Increment 속성에 지정된 값만큼 증가시키거나 감소시킵니다.
NumericUpDown1.UpButton()
numericUpDown1.UpButton();
numericUpDown1.UpButton();
numericUpDown1->UpButton();
숫자 값을 반환하려면
코드를 작성하여 Value 속성에 액세스합니다.
If NumericUpDown1.Value >= 65 Then MessageBox.Show("Age is: " & NumericUpDown1.Value.ToString) Else MessageBox.Show("The customer is ineligible for a senior citizen discount.") End If
if(numericUpDown1.Value >= 65) { MessageBox.Show("Age is: " + numericUpDown1.Value.ToString()); } else { MessageBox.Show("The customer is ineligible for a senior citizen discount."); }
if (Decimal.Compare(numericUpDown1.get_Value(), new Decimal(65)) >= 0) { MessageBox.Show(("Age is: " + numericUpDown1.get_Value().ToString())); } else { MessageBox.Show("The customer is ineligible for a senior citizen discount."); }
if(numericUpDown1->Value >= 65) { MessageBox::Show(String::Concat("Age is: ", numericUpDown1->Value.ToString())); } else { MessageBox::Show ("The customer is ineligible for a senior citizen discount."); }
참고 항목
참조
NumericUpDown 컨트롤 개요(Windows Forms)