繁体   English   中英

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

[英]move the label from left to right in table layout panel c#

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

public partial class Form1: Form
    {
        int x = 25, y = 1;
        public Form1()
        {
            InitializeComponent();
        }



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

        private void Form1_Load(object sender, EventArgs e)
        {
            label1.Text = "hii";
            label1.Font = new Font(" ", 22, FontStyle.Bold);
            timer1.Interval = 10;
            timer1.Start();
        }
    }

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

    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();
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM