问题描述
- 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"; } //} }
- List item
`
解决方案
将位置换一下
lb1.Text = "jishu";
this.Controls.Add(lb1);
时间: 2024-11-03 21:59:40