如题...
解决方案 »
- c#中对于多态的定义是什么?怎么说什么定义的都有啊????
- GridView1导出文本包含HTML源吗?何解?
- c# winform简单问题。如何获取指定y坐标所有控件。
- 在winform如何判断正确的email格式?
- dateTimePicker控件源代码
- 使用XMLHTTPClass 和 HttpWebRequest 不能获得相应数据
- 请教高手成绩的正则表达式怎么写,谢谢!!!
- 如何提升自己操作注册表的权限,达人进来阿,挽救小生,顶者有分
- 昨天面试的时候碰到的一个问题,自己太菜,求助一下,主要是想弄明白怎么解决问题。3Q
- net_lover,专家,您好! 请问DataGridView编辑修改完后,提交到DataSet的正确写法是怎样?
- 高分求助:如何在设计器中修改用户控件里面的控件属性
- ASP.NET中文件上传
timer里面原有的值会不会被清除?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace WindowsApplication9
{
public partial class Form1 : Form
{
int second;//second 是秒数
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{ } private void timer1_Tick(object sender, EventArgs e)
{
second++;//开始计时
this .Text =second .ToString();//在窗体标题栏显示时间,随便找个地方显示的,
} private void button1_Click(object sender, EventArgs e)
{
timer1.Interval = 1000;//每秒执行一次
timer1.Enabled = true;//timer开始
} private void button2_Click(object sender, EventArgs e)
{
timer1.Enabled = false;//timer暂停
}
}
}
timer.Stop();
未尝不可?
定义一个全局的 Stopwatch stop = new Stopwatch();
long time=0;
在
private void timer1_Tick(object sender, EventArgs e)
{
if(time>0)
{
timer1.Interval-=time;
time=0;
}
else
{
timer1.Interval=value;//value为你自己定义的值
}
………
stop.Reset();
stop.Start();//在timer函数的结尾开始计时;
}
private void button1_Click(object sender, EventArgs e)
{
time=stop.ElapsedMilliseconds;//获取时间差。用你的timer1.Interval值减去time就是下次timer控件触发的时间
}
相信这段代码能满足你的要求吧