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();
                }
            }
        }
    }
    

     

     

  • 相关阅读:
    CodeForces 660D Number of Parallelograms
    【POJ 1082】 Calendar Game
    【POJ 2352】 Stars
    【POJ 2481】 Cows
    【POJ 1733】 Parity Game
    【NOI 2002】 银河英雄传说
    【NOI 2015】 程序自动分析
    【POJ 1704】 Georgia and Bob
    【HDU 2176】 取(m堆)石子游戏
    【SDOI 2016】 排列计数
  • 原文地址:https://www.cnblogs.com/my-cat/p/7267306.html
Copyright © 2011-2022 走看看