每次选中复选框时,我都希望能够以增量方式添加到进度条。因此,假设 4 个复选框中有 1 个是选中的,那么它将等于进度条的 25%。此外,如果您取消选中 4 个复选框之一,进度条将相应减少。这就是我所坚持的。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void progressBar1_Click(object sender, EventArgs e)
{
progressBar1.Minimum = 0;
progressBar1.Maximum = 100;
int num1 = progressBar1.Maximum / 4;
int num2 = progressBar1.Maximum / 4;
int num3 = progressBar1.Maximum / 4;
int num4 = progressBar1.Maximum / 4;
int numAns;
numAns = num1 + num2 + num3 + num4;
progressBar1.Value = numAns;
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if(checkBox1.Checked == true)
{
}
else if (checkBox1.Checked == false)
{
}
}
private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
}
private void checkBox3_CheckedChanged(object sender, EventArgs e)
{
}
private void checkBox4_CheckedChanged(object sender, EventArgs e)
{
}
}
}