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

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);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办