0

I want to make a button when you click it one time it will say "Stop" and when you click it a second time it will say "Start" and I'm new to visual studio and C# so it's taking time to research. So if anyone could help I would be honored.

so it's just a button that changed it's name when you click it.

2
Contributors
3
Replies
14
Views
1 Year
Discussion Span
Last Post by tinstaafl
1

What you need to do is handle the click event of the button, then check the current text of the button and act accordingly. To create the handler template, one of the easiest ways is to double-click the button and VS will automatically create the template, ready for you to add the code you need.

Edited by tinstaafl

0

Thanks for the help, I figured it all out now, this is what I did to fix it.

private void button2_Click(object sender, EventArgs e)
{
            if  (button2.Text == "Stop")
            {
                button2.Text = "Go";
            }
            else if (button2.Text == "Go")
            {
                button2.Text = "Stop";
            }
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.