zoukankan      html  css  js  c++  java
  • 练习:WinForm 跑马灯效果+Timer

    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 Timer
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            /// <summary>
            /// 跑马灯效果
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void timer1_Tick(object sender, EventArgs e)
            {
                label1.Text=label1.Text.Substring(1) + label1.Text.Substring(0, 1);
            }
    
            /// <summary>
            /// 每隔一秒钟就把当前的时间赋值给label2
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void timer2_Tick(object sender, EventArgs e)
            {
                 label2.Text=DateTime.Now.ToString();
                 //指定时间播放闹铃
                //if(DateTime.Now.Hour==16 && DateTime.Now.Minute==00 && DateTime.Now.Second==00)
                //{
                //    Soundplayer sp = new Soundplayer();
                //    sp.SoundLocation = @"路径.wav";
                //    sp.play();
                //}
            }
    
            /// <summary>
            /// 当窗体加载的时候,将当前时间赋值给label2
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void Form1_Load(object sender, EventArgs e)
            {
                label2.Text = DateTime.Now.ToString();
            }
    
            private void label1_Click(object sender, EventArgs e)
            {
    
            }
        }
    }

  • 相关阅读:
    vue3_10 吴小明
    ios圆角属性失效的解决办法 吴小明
    vue3_07 吴小明
    vue3_04 吴小明
    vue3_08 吴小明
    vue3_09 吴小明
    vue指定返回键的路由(点击浏览器的返回按钮/beforeRouterLeave) 吴小明
    Object.assign() 吴小明
    vue中使用lodash的debounce(防抖函数) 吴小明
    读雪中悍刀行有感
  • 原文地址:https://www.cnblogs.com/xiao55/p/5628451.html
Copyright © 2011-2022 走看看