求一个WinForm 计时器
来源:百度知道 编辑:UC知道 时间:2024/05/30 06:23:42
偶使用 VS2003 为你编写,已通过调试:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace WindowsApplication1
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
private bool isStart = false; // 记录是否启动
private int cnt; // 已经计时的次数
private DateTime beginTime; // 记录启动时的时间
const string FileName = "C:\\time.txt"; // 保存日志的文件名
private System.Windows.Forms.Timer timer1;
private System.ComponentModel.IContainer components;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponen