网站底部固定代码,网站建设税收编码,服务公司名字大全,这么攻击网站C# Timer定时器
Timer定时器定时器主要用到的就是Timer的Tick事件#xff0c;另外还要设置时间间隔#xff1a; 下面这个实力演示了每隔一秒#xff0c;picturebox中的图片来回切换#xff0c;每隔一秒#xff0c;文本框中显示当前时间。
using System;
using System.Co…C# Timer定时器
Timer定时器定时器主要用到的就是Timer的Tick事件另外还要设置时间间隔 下面这个实力演示了每隔一秒picturebox中的图片来回切换每隔一秒文本框中显示当前时间。
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 WindowsFormsApp2
{public partial class Form6 : Form{public Form6(){InitializeComponent();}string path1 E:\朱维照片\创作照\1.jpg;string path2 E:\朱维照片\创作照\2.jpg;bool flag true;private void button1_Click(object sender, EventArgs e){timer1.Interval 1000;timer1.Start();}private void timer1_Tick(object sender, EventArgs e){textBox1.Text DateTime.Now.ToString();if (flag){pictureBox1.Image Image.FromFile(path1);pictureBox1.SizeMode PictureBoxSizeMode.Zoom;flag false;}else{pictureBox1.Image Image.FromFile(path2);pictureBox1.SizeMode PictureBoxSizeMode.Zoom;flag true;}}private void button2_Click(object sender, EventArgs e){timer1.Stop();}}
}