在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
源码下载:http://www.0379zd.com/news/show/26100.htm
using System;
using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { if (timer1.Enabled == true) { timer1.Enabled = false; button1.Text = "开始"; } else { timer1.Enabled = true; button1.Text = "停止"; } } private void trackBar1_Scroll(object sender, EventArgs e) { //使用trackBar1调整步进速度,不能为零 timer1.Interval = Convert.ToInt16(5000 / trackBar1.Value); } private void timer1_Tick(object sender, EventArgs e) { if (this.progressBar1.Value == this.progressBar1.Maximum) { this.progressBar1.Value = this.progressBar1.Minimum; } else { //主要是这个函数,步进 this.progressBar1.PerformStep(); } //计算百分比 int intPercent; intPercent = 100 * (this.progressBar1.Value - this.progressBar1.Minimum) / (this.progressBar1.Maximum - this.progressBar1.Minimum); label1.Text = Convert.ToInt16(intPercent).ToString() + "%"; } private void Form1_Load(object sender, EventArgs e) { this.progressBar1.Maximum = 1000; this.progressBar1.Step = 10; } } } |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论