C# 走马灯 代码可直接复制使用

C# <wbr>走马灯 <wbr>代码可直接复制使用
 C# Code 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using  System;
using  System.Collections.Generic;
using  System.ComponentModel;
using  System.Data;
using  System.Drawing;
using  System.Linq;
using  System.Text;
using  System.Windows.Forms;

namespace  走马灯
{
    
public  partial  class  Form1 : Form
    {
        
int  flag =  0 ;
        
public  Form1()
        {
            InitializeComponent();
        }
        
//要求:
         //当点击左移按钮的时候不断左移,当点击右移按钮的时候不断右移,当点击暂停按钮的时候暂停
         private   void  button1_Click( object  sender, EventArgs e)
        {

            flag = 
1 ; //左移


             //while (flag == 1)
             //{
             //    string Input = textBox1.Text;
             //    char leftInput = Input[0];
             //    string ringhtInput = Input.Substring(1);
             //    textBox1.Text = ringhtInput + leftInput;
             //}
        }

        
private   void  button2_Click( object  sender, EventArgs e)
        {

            flag = 
2 ; //右移

             //while (flag == 2)
             //{
             //    string Input = textBox1.Text;
             //    char leftInput = Input[Input.Length - 1];
             //    string ringhtInput = Input.Substring(0, Input.Length - 1);
             //    textBox1.Text = leftInput + ringhtInput;
             //}

        }
        
private   void  btnpause_Click( object  sender, EventArgs e)
        {
            flag = 
0 ; //暂停
        }

        
private   void  timer1_Tick( object  sender, EventArgs e) //在timer的tick事件中写
        {

            
if  (flag ==  1 )
            {
                
//不断取出第一位移到最后一位后面
                 string  Input = textBox1.Text;
                
char  leftInput = Input[ 0 ];
                
string  ringhtInput = Input.Substring( 1 );
                textBox1.Text = ringhtInput + leftInput;
            }
            
if (flag ==  2 )
            {
                
//不断取出最后一位移到第一位前面
                 string  Input = textBox1.Text;
                
char  leftInput = Input[Input.Length -  1 ];
                
string  ringhtInput = Input.Substring( 0 , Input.Length -  1 );
                textBox1.Text = leftInput + ringhtInput;
            }
        }




    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AIGIS.

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值