0

I am trying to change the textbox text if I click the button:

    private void button1_Click(object sender, EventArgs e)
    {
     string Tag = (string)button1.Tag;

        switch (Tag)
        {
            case "quest1_1":
                textBox1.Text = "test";
                button1.Tag = "quest1_2";
                break;

            case "quest1_2":
                textbox1.Text = "example text";
                button1.Tag = "quest1_3";
                break;

            default:
                textbox1.Text = "";
                button1.Tag = "";
                break;
        }
        }

The problem is that this code worked in another project but here it doesn't. If I start the application and click button1, nothing happens.

Can you help me with that?

4

2 回答 2

0
  1. Is button1_Click a listener on the button's click event? Set a breakpoint in this routine and see if you get there when you click.
  2. Is button1.Tag set to anything by default? The debugger will tell you that, too.
于 2013-07-20T22:08:27.713 回答
0

如果按钮的标签设置为“”,则既不是“quest1_1”也不是“quest1_2”的情况,它是默认情况。在您的默认设置中,您使用这个:

textbox1.Text = "";
button1.Tag 
break;

这意味着将文本框文本设置为空,因此没有任何反应是很正常的。

于 2013-07-20T22:20:28.910 回答