A
A
Andrew2015-08-01 12:23:55
WPF
Andrew, 2015-08-01 12:23:55

How to add a unit to the existing value in the Label?

The form has "label1" and "+" and "-" buttons.
How to make it so that when you click on the "+" button, the value in "label1" increases by one, up to nine.
I know it's not that hard, but I can't.

private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            int t= 1;
            if (t < 9)
            {
                t++;
                label1.Content = t.ToString();
            }
        }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2015-08-01
@GavriKos

Dotnet has a separate component for this - NumericUpDown is called. All you need he can do.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question