在表格布局面板c#中从左向右移动标签

时间:2019-03-06 08:55:06

标签: c# label tablelayout

我有这段代码,当我运行它时,它已经移动了,但屏幕上显示了两个标签,一个是不动,一个是动了

checkSchedule()

1 个答案:

答案 0 :(得分:0)

您必须在工具箱中再添加一个标签才能形成表单。在计时器中设置新标签的范围也是如此:

    int x = 25, y = 1;
    public Form1()
    {
        InitializeComponent();
    }


    private void timer1_Tick_1(object sender, EventArgs e)
    {
        label1.SetBounds(x, y, 255, 255);
        label2.SetBounds(x, 100, 255, 255);
        x++;
        if (x >= 800)
        {
            x = 1;
        }
    }

    private void Form1_Load_1(object sender, EventArgs e)
    {
        label1.Text = "hii";
        label1.Font = new Font(" ", 22, FontStyle.Bold);

        label2.Text = "hii2";
        label2.Font = new Font(" ", 22, FontStyle.Bold);

        timer1.Interval = 10;
        timer1.Start();
    }