c#-cycle scrolling subtitles, timer, left to right, right to left, pause---shinepans

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.