timer控件 倒计时 顺时计时 重置计时

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace Remind{ public partial class Form1 : Form { public Form1() { InitializeComponent(); }
private void Form1_SizeChanged(object sender, EventArgs e) { if (this.WindowState == FormWindowState.Minimized) //判断是否最小化 { this.ShowInTaskbar = false; //不显示在系统任务栏 notifyIcon1.Visible = true; //托盘图标可见 } } private void notifyIcon1_DoubleClick(object sender,
EventArgs e) { if (this.WindowState == FormWindowState.Minimized) { this.ShowInTaskbar = true; //显示在系统任务栏 this.WindowState = FormWindowState.Normal; //还原窗体 notifyIcon1.Visible = false; //托盘图标隐藏 } } private int temptime = 0; // private int temptime2 = 0; private
void button1_Click(object sender, EventArgs e) { //开始 timeStart(); } private void timeStart() { if (string.IsNullOrEmpty(textBox1.Text)) { MessageBox.Show("分钟数不能为空"); return; } if(timer1.Enabled) { MessageBox.Show("亲!计时已经开始了"); return; } temptime = int.Parse(textBox1.Text)
* 60; timer1.Tick += new EventHandler(timer1_Tick); timer1.Interval = 1000; timer1.Enabled = true; timer1.Start(); } private void Form1_Load(object sender, EventArgs e) { TimeSpan st = new TimeSpan(0, 0, Convert.ToInt32( textBox1.Text)*60); TimeSpan st2 =
new TimeSpan(0, 0, temptime2); //倒时 lbltime.Text = st.ToString(); //顺时 lbltime2.Text = st2.ToString(); } private void timer1_Tick(object sender, EventArgs e) { temptime = temptime - 1; temptime2 = temptime2 + 1; if(temptime<=0) { //如果最小化在系统托盘,倒时完成将弹出来 if (this.WindowState
== FormWindowState.Minimized) { this.ShowInTaskbar = true; //显示在系统任务栏 this.WindowState = FormWindowState.Normal; //还原窗体 notifyIcon1.Visible = false; //托盘图标隐藏 timer1.Stop(); timer1.Enabled = false; timer1.Dispose(); } MessageBox.Show("亲!设置的分钟数已经走完了"); this.Dispose();
System.Diagnostics.Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location); } TimeSpan st = new TimeSpan(0, 0, temptime); TimeSpan st2 = new TimeSpan(0, 0, temptime2); //倒时 lbltime.Text = st.ToString(); //顺时 lbltime2.Text = st2.ToString();
} private void button2_Click(object sender, EventArgs e) { //重置 this.Dispose(); System.Diagnostics.Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location); } private void textBox1_TextChanged(object sender, EventArgs e) { } }}

下载地址:http://download.csdn.net/detail/querystringcom/8724943

时间: 2024-08-30 17:55:17

timer控件 倒计时 顺时计时 重置计时的相关文章

VB中如何timer 控件进行倒计时

1.程序加载时操作: Private Sub Form_Load() '窗体加载时自动进行Timer1.Interval = 1000 '设置计时周期为1秒注意默认计时单位为毫秒,即1/1000秒 2.定义一个时间变量.可以某控件的Caption属性代替,如Label12.Caption 3.拖放timer控件到程序界面上4.设置倒计时:双击时钟控件,输入计时规则,如Label12.Caption = Label12.Caption + 15.设置当时间值达到某一条件的时候应采取的方法(即动作)

10、面向对象以及winform的简单运用(isMdicontainer的设置、timer控件进行倒计时的制作)

IsMdicontainer的设置 这是对于整个窗体的设置,将一个窗体的IsMdicontainer设置为true之后,再打开新窗体便可以让新窗体被父容器包括在内. 操作方法: 1)先建立一个子窗体Child.cs 2)在父容器的按钮里写代码,打开子窗体 Child c = new Child(); //判断窗体是否已经打开,以控制其只能打开一个 int count = 0; foreach (Form f in this.MdiChildren) { if (f.Name == c.Name)

C# 如何用计时器Timer控件实现停留几秒再做切换窗体的操作

C# Timer用法及实例详解 关于C# Timer类  在C#里关于定时器类就有3个 C# Timer使用的方法1.定义在System.Windows.Forms里 C# Timer使用的方法2.定义在System.Threading.Timer类里  " C# Timer使用的方法3.定义在System.Timers.Timer类里 ◆System.Windows.Forms.Timer 应用于WinForm中的,它是通过Windows消息机制实现的,类似于VB或Delphi中的Timer控

IsMdicontainer新窗体被父容器包括的设置、Timer控件

IsMdicontainer的设置 这是对于整个窗体的设置,将一个窗体的IsMdicontainer设置为true之后,再打开新窗体便可以让新窗体被父容器包括在内. 操作方法: 1)先建立一个子窗体Child.cs 2)在父容器的按钮里写代码,打开子窗体 Child c = new Child(); //判断窗体是否已经打开,以控制其只能打开一个 int count = 0; foreach (Form f in this.MdiChildren) { if (f.Name == c.Name)

WinForm Timer控件,三级联动[省,市,区]

Timer控件: 组件中的最后一个控件,功能是可以根据用户自定义的时间间隔来触发时间,不会印象窗体本身的其他事件进行. 属性: Enable  设置控件是否启用 Interval  设置事件的频率,以毫秒为单位 事件只有一个:Tick事件 例:使用timer控件获取当前时间并即时变动 private void timer1_Tick(object sender, EventArgs e) { label1.Text = DateTime.Now.ToString("yyyy年MM月dd日hh时m

WinForm用户控件、动态创建添加控件、timer控件--2016年12月12日

好文要顶 关注我 收藏该文 徐淳 关注 - 1 粉丝 - 3 0 0 用户控件: 通过布局将多个控件整合为一个控件,根据自己的需要进行修改,可对用户控件内的所有控件及控件属性进行修改使用 动态创建添加控件: 1 //定义控件类型 2 Button btn = new Button(); 3 //控件名称……等属性,也可以直接绑定各种事件 4 btn.Name = "mybutton" + i.ToString(); 5 //添加到窗体 this 可以替换为 容器控件 6 this.Co

无边框窗体 timer控件

一.无边框窗体1.控制按钮如何制作 MouseEnter-鼠标移入的时候发生的事件 pictureBox1.BackgroundImage = Image.FromFile(Application.StartupPath + "\\..\\..\\images\\btn_close_highlight.png"); MouseLeave-鼠标移出的时候发生的事件 pictureBox1.BackgroundImage = Image.FromFile(Application.Start

WinForm timer控件

timer 控件:按用户定义的时间间隔引发的事件 属性: Enabled   是否启用:  Interval    事件发生的事件间隔,单位是毫秒 事件只有一个:Tick    事件经过指定的时间间隔发生 打开一个窗口,获取同步时间(精确到秒) 首先在构造函数中设置初始状态 public Form1() { InitializeComponent(); label3.Text = DateTime.Now.ToString("yyyy年MM月dd日hh时mm分ss秒"); 其次设置在T

timer控件、三级联动

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