Justin_zhao 2014-11-14 04:07 采纳率: 0%
浏览 2747

C# button_click事件中new了一个label 但是每次点击的时候label无法切换文字

代码如下:` private void button1_Click(object sender, EventArgs e)
{

        //using (Label lb = new Label())
        //{
        //    lb.Location = new Point(20, 20);
        //    this.Controls.Add(lb);
        Label lb2 = new Label();
        Label lb1 = new Label();
            count += 1;
            int i = count % 2;
            if (i == 0)
            {
                this.Controls.Remove(lb2);
                this.Controls.Add(lb1);
                lb1.Text = "jishu";

            }
            else
            {
                this.Controls.Remove(lb1);
                this.Controls.Add(lb2);
                lb2.Text = "oushu";

            }
        //}

    }
  1. List item

`

  • 写回答

1条回答 默认 最新

  • 张云勇 2014-11-18 05:19
    关注

    将位置换一下

    lb1.Text = "jishu";
     this.Controls.Add(lb1);
    
    评论

报告相同问题?