private void timer1_Tick(object sender, EventArgs e)
{
Point p = new Point(tbText.Location.X + 1, tbText.Location.Y);
tbText.Location = p;//tbText为TextBox控件ID
if (p.X > 300)
{
timer1.Enabled = false;
timer2.Enabled = true;
}
}
private void timer2_Tick(object sender, EventArgs e)
{
Point p=new Point(tbText.Location.X-1,tbText.Location.Y);
tbText.Location=p;
if (p.X < 9)
{
timer1.Enabled = true;
timer2.Enabled = false;
}
}
注意:运行前,一定要首先检查timer1控件的Enabled属性(默认是false),修改为True
若没修改,则运行是不会滚动的