1 #regionMarquee Effect Method2 /// <summary>3 ///the text goes to the left and comes out from the right.4 /// </summary>5 Private voidLabelrun ()6 {7 if((lbmsg.location.x + lbmsg.width) >0)8 {9Lbmsg.left = Lbmsg.left-5;Ten } One Else//set Text initial position A { -Lbmsg.left =Pbox.width; - } the } - - BOOLFlag =true;//Mark text Scroll line true--toward left false--to right - /// <summary> + ///text colliding back and forth inside the container - /// </summary> + Private voidLabelrunex () A { at if(flag) - { - if(Lbmsg.left >0)//determines whether the text start collides to the left edge of the container - { -Lbmsg.left = Lbmsg.left-5; - if(Lbmsg.left <=0) in { -Flag =false; to } + } - } the Else * { $Lbmsg.left = Lbmsg.left +5;Panax Notoginseng if(Lbmsg.left >= pbox.width-lbmsg.width)//determines whether the end of the text collides to the right edge of the container - { theFlag =true; + } A } the } + #endregion
Method
1 #regionMarquee Thread2 NewThread (() =3 {4 while(true)5 {6 Try7 {8 Labelrunex ();9 }Ten Catch { } OneThread.Sleep ( -); A } - }) -{IsBackground =true }. Start (); the #endregion
called
C # Analog Marquee effect (2 kinds)