The left property of the lable can be changed, but the right property cannot be changed, so we can use this feature to do the self-subtraction operation
Using system;using system.collections.generic;using system.componentmodel;using system.data;using System.Drawing; Using system.linq;using system.text;using system.threading.tasks;using system.windows.forms;namespace Scrolling caption {public Partial class Form1:form {public Form1 () {InitializeComponent (); private void Timer1_Tick (object sender, EventArgs e) {this.label2.Left + = 8; Move right 3 pixels if (this.label2.left>this. Width) {this.label2.Left = 0-label2. Width; Label left position is current control width}} private void Button1_Click (object sender, EventArgs e) {thi S.timer2.stop (); This.timer1.Start (); Open timer} private void Button2_Click (object sender, EventArgs e) {this.timer1.Stop ();//Stop Stop timer this.timer2.Stop (); private void Button3_Click (object sender, EventArgs e) {this.timer1.Stop(); This.timer2.Start (); private void Timer2_tick (object sender, EventArgs e) {this.label2.Left-= 8; Move right 3 pixels if (this.label2.Right <0) {this.label2.Left = this. Width; The left position of the label is the current control width}}}}
Effect:
Code:
Http://yunpan.cn/csJUp3DFkakCZ Extract Code b050
c#-cycle scrolling subtitles, timer, left to right, right to left, pause---shinepans