日期:2014-05-20  浏览次数:20765 次

想做一个在panel中飞过的文本的效果,结果只显示最后的一个,怎么改!
for   (int   j   =   1;   j   <   20;   j++)
                        {      
                                panel1.Controls.Clear();
                                Label   hj   =   new   Label();
                                hj.Name   =   "hj "   +   i;
                                hj.Text   =   "2wqwer ";
                                hj.Location   =   new   System.Drawing.Point(10   *   i,   10   *   i);
                                //hj.Width   =   100;
                                //hj.Height   =   20;
                                panel1.Controls.Add(hj);
                                Thread.Sleep(10);
                          }

------解决方案--------------------
for (int i = 1; i < 20; i++) // j -> i
{
panel1.Controls.Clear();
Label hj = new Label();
hj.Name = "hj " + i;
hj.Text = "2wqwer ";
hj.Location = new System.Drawing.Point(10 * i, 10 * i);
panel1.Controls.Add(hj);
Application.DoEvents(); // < < insert
Thread.Sleep(10);
}