Nasıl yapılır: Windows Forms NumericUpDown Denetimi ile Sayısal Değerler Ayarlama ve Döndürme

Windows Forms NumericUpDown denetiminin sayısal değeri, Value özelliği tarafından belirlenir. Denetimin değeri için diğer tüm özelliklerde olduğu gibi koşullu testler yazabilirsiniz. Value özelliği ayarlandıktan sonra, üzerinde işlem gerçekleştirmek için kod yazarak doğrudan ayarlayabilir veya UpButton ve DownButton yöntemlerini çağırabilirsiniz.

Sayısal değeri ayarlamak için

  1. Koddaki veya Özellikler penceresindeki Value özelliğine bir değer atayın.

    NumericUpDown1.Value = 55
    
    numericUpDown1.Value = 55;
    
    numericUpDown1->Value = 55;
    

    -veya-

  2. değeri UpButton özelliğinde belirtilen miktarda artırmak veya azaltmak için DownButton veya Increment yöntemini çağırın.

    NumericUpDown1.UpButton()
    
    numericUpDown1.UpButton();
    
    numericUpDown1->UpButton();
    

Sayısal değeri döndürmek için

  • Koddaki Value özelliğine erişin.

    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(numericUpDown1->Value >= 65)
    {
       MessageBox::Show(String::Concat("Age is: ",
          numericUpDown1->Value.ToString()));
    }
    else
    {
       MessageBox::Show
          ("The customer is ineligible for a senior citizen discount.");
    }
    

Ayrıca bakınız