C# winform 定时器

编程入门 行业动态 更新时间:2024-10-24 09:24:53

C# winform <a href=https://www.elefans.com/category/jswz/34/1768257.html style=定时器"/>

C# winform 定时器

1.加入Timer

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;namespace TestTimer
{public partial class Form1 : Form{int systemCounter = 0; public Form1(){InitializeComponent(); //设置Timer1控件可用this.timer1.Enabled = false;//设置Timer1 时间间隔this.timer1.Interval = 5000; } //打開服務private void openbutton_Click(object sender, EventArgs e){systemCounter = 0;this.timer1.Start();} //关闭线程private void stopbutton_Click(object sender, EventArgs e){this.timer1.Stop();}//循环执行的事件private void timer1_Tick(object sender, EventArgs e){systemCounter += 1; this.textBox1.Text ="現在的數據是"+ systemCounter.ToString().Trim(); }}
}

更多推荐

C# winform 定时器

本文发布于:2023-11-16 09:45:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1616403.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:定时器   winform

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!