[英]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.