zoukankan      html  css  js  c++  java
  • 文本滚动和计时

    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;
    using System.Diagnostics;//计时相关
    
    namespace 文本的滚动
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                //可以初始化form上的控件
                textBox1.Text = "huaimaomaopolanlan";
            }
    
            private void btnLeft_Click(object sender, EventArgs e)
            {
                
                for(int i = 0; i  < textBox1.Text.Length;i++)
                {
                    //              取从第二个开始的剩余部分      取第一个字
                    textBox1.Text = textBox1.Text.Substring(1) +  textBox1.Text.Substring(0, 1);
                    System.Threading.Thread.Sleep(500);
                    textBox1.Update();
                }
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                Stopwatch watch = new Stopwatch();
                watch.Start();
                for( int i = 0; i <= 1000;  i++)
                {
                    textBox2.Text = i.ToString();
                    //textBox2.Update();
                }
                watch.Stop();
                MessageBox.Show(string.Format("用时为:{0}", watch.Elapsed.Milliseconds));
            }
    
            private void btnRight_Click(object sender, EventArgs e)
            {
                for (int i = 0; i < textBox1.Text.Length; i++)
                {
                    //              取最后一个字                                       取剩余部分
                    textBox1.Text = textBox1.Text.Substring(textBox1.Text.Length -1) + textBox1.Text.Substring(0, textBox1.Text.Length-1);
                    System.Threading.Thread.Sleep(500);//0.5秒
                    textBox1.Update();
                }
            }
        }
    }
    

     

     

  • 相关阅读:
    RDS 工作笔记
    网站测试需要提供的参数和结果分析
    php 安全编程
    留住青春的格子
    保持工作精力旺盛的方法
    百万格子的标签认领可以提高你在alexa的排名的格子
    老电影,似水流年的记忆
    五行 八字 计算
    iis6.0 的 性能比较
    各种情绪和调节方法
  • 原文地址:https://www.cnblogs.com/my-cat/p/7267306.html
Copyright © 2011-2022 走看看