练习:WinForm 跑马灯效果+Timer
2016-06-29 22:29
295 查看
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) { } } }
![](https://images2015.cnblogs.com/blog/894738/201606/894738-20160629222740437-397919957.png)
![](https://images2015.cnblogs.com/blog/894738/201606/894738-20160629222751671-121538430.png)
![](https://images2015.cnblogs.com/blog/894738/201606/894738-20160629222801390-246840482.png)
相关文章推荐
- MarkdownPad2 下一些设置
- linux 安装git
- IHTMLObjectElement
- 常见的网站攻击以及如何防御自己的网站被恶意攻击
- HDU 4779 Tower Defense(组合数学)
- 许三观卖血记
- 过滤器(Filter)和拦截器(Interceptor)的区别
- PGP简介
- Python 线程只join
- 全局变量和局部变量在内存中的区别
- Windows批处理BAT脚本查询PM2.5实时空气质量指数(AQI)
- Android中的RSA加密
- 编写C语言版本的卷积神经网络CNN之二:CNN网络的总体结构
- ajax详解
- 创业的第二百零九天
- 【图像处理】常用色彩空间
- JSON数据解析之苹果原生
- SQL Server2008函数大全(完整版)
- 如何选择合适的项目开发方式
- day_04_python内置函数01