Search code examples
c#numericupdown

Trying to subtract setup from cost in a NumericUpDown


I am trying to subtract setup from cost. So, I need to get the value from the NumericUpDown box and store it to an integer, which I can then use to subtract setup from.

public partial class Form1 : Form
{
    int setup = 100;
    int finalcost;
    int cost;
    int priority;

    public Form1()
    {
        InitializeComponent();
    }

    private void button2_Click(object sender, EventArgs e)
    {
        priority = trackBar1.Value;
        int cost = (int)numericUpDown1.Value;
        if (radioButton1.Checked)
        {

            finalcost = cost - setup;
            MessageBox.Show(finalcost.ToString());
        }
    }

Solution

  • Set the NumericUpDown Maximum property to higher than 100.