功能:实现控制数字变化过程
功能效果图
代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace gundon
{
public partial class Form1 : Form
{
Double index = 1;
public Form1()
{
InitializeComponent();
timer1.Interval = 100;//变化时间间隔100 = 0.1秒
timer1.Tick += new EventHandler(timer1_Tick);//绑定间隔事件
}
private void timer1_Tick(object sender, EventArgs e)
{
index ++;//数字变化,自增1
l1.Text = index.ToString();
}
private void button1_Click(object sender, EventArgs e)
{
timer1.Enabled = false;//关闭定时器
}
private void l1_Click(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
timer1.Enabled = true;//开启定时器
}
private void button3_Click(object sender, EventArgs e)
{
Application.Exit();//退出程序
}
}
}