我想在Winform中做一个跑马灯,也就是让一行字在上面滚动,上次在这里发帖了,但是效果不怎么好,我现在不想用timer控件+label来实现,因为这样的效果是跳动的,如果在屏幕上显示效果不好。我想用pictures重绘,因为我最终是在显示在Led显示屏上面,具体要求就是滚动的范围可以自己设置,效果是平滑滚到,不是跳动的。希望大家帮我想想,如果问题解决了,我还会加分的。

解决方案 »

  1.   

    timer控件+label实现起来应该很好的呀
      

  2.   

     private void timer1_Tick(object sender, EventArgs e)
            {
                if (labMsg.Location.X < 0 && Math.Abs(labMsg.Location.X) - labMsg.Width >= 0)
               {
                    labMsg.Location = new Point(panel1.Width, labMsg.Location.Y);
                    return;
                }
               labMsg.Location = new Point(labMsg.Location.X - 5, labMsg.Location.Y);
            }
            [Category("Appearance"),
                       Description("Label前景色")]
            public System.Drawing.Color LabelForeColor
           {
                get { return labMsg.ForeColor; }
                set { labMsg.ForeColor = value; }
           }        [Category("Appearance"),
                       Description("LabelText")]
            public string LabelText
            {
               get { return labMsg.Text; }
                set
                {                labMsg.Text = value;
                    if (value == "")
                        timer1.Enabled = false;
                    else timer1.Enabled = true;
                }
            }
      

  3.   

    我觉得还是该timer实现,或者线程sleep,
      

  4.   

    我想应该是你的timer控件的速度是不是有点慢的问题还是怎末回事 应该来说不会出现你说的那种问题
      

  5.   

    timer间隔短一点,移动的慢一点
      

  6.   

    以前用vb6写过一个,timer+panel,panel自适应背景。
    还有一个方法就是用API来做,以前看过一个VB6的例子,那个效果比较好,平滑。
      

  7.   

    很久没winforms了
    还是帮你顶哈
      

  8.   

    webBrowser包装个html标签跑马 也是个思路哦 
      

  9.   

      结贴了。自己的方法:
       
       public static int x = 0;
            public static float w = 0;//滚到的长度
            public static float step = 0; //每次滚动的像素
            public static string data = "";//滚到的内容
            public static Font myfont = new Font("宋体",12);
            public static Color picScollColor = Color.Green;
          
            //滚动条滚动
            private void timer2_Tick(object sender, EventArgs e)
            {
                if (step > w)
                {
                    x = picScoll.Width;
                    step = 0;
                }
         
                Bitmap myPic = new Bitmap(picScoll.Width,  myfont.Height);
                Graphics g = Graphics.FromImage(myPic);
                SizeF f = g.MeasureString(data,myfont);
                w = f.Width + picScoll.Width;
                Brush brush = new SolidBrush(picScollColor);
                g.DrawString(data,myfont ,brush ,new Point (x,0));
             
                picScoll.Image = myPic;
                step++;
                x--;
                       }   
      

  10.   

    用委托来异步调用吧,用GDI+实现重绘picturebox,用双缓冲减少闪烁。应该可以吧。。我也是个菜鸟,大家一起学学吧