当前位置: 首页>>代码示例>>C#>>正文


C# ProgressBar.Maximum属性代码示例

本文整理汇总了C#中System.Windows.Forms.ProgressBar.Maximum属性的典型用法代码示例。如果您正苦于以下问题:C# ProgressBar.Maximum属性的具体用法?C# ProgressBar.Maximum怎么用?C# ProgressBar.Maximum使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在System.Windows.Forms.ProgressBar的用法示例。


在下文中一共展示了ProgressBar.Maximum属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CopyWithProgress

private void CopyWithProgress(string[] filenames)
{
    // Display the ProgressBar control.
    pBar1.Visible = true;
    // Set Minimum to 1 to represent the first file being copied.
    pBar1.Minimum = 1;
    // Set Maximum to the total number of files to copy.
    pBar1.Maximum = filenames.Length;
    // Set the initial value of the ProgressBar.
    pBar1.Value = 1;
    // Set the Step property to a value of 1 to represent each file being copied.
    pBar1.Step = 1;
    
    // Loop through all files to copy.
    for (int x = 1; x <= filenames.Length; x++)
    {
        // Copy the file and increment the ProgressBar if successful.
        if(CopyFile(filenames[x-1]) == true)
        {
            // Perform the increment on the ProgressBar.
            pBar1.PerformStep();
        }
    }
}
开发者ID:.NET开发者,项目名称:System.Windows.Forms,代码行数:24,代码来源:ProgressBar.Maximum

示例2: ProgressBars

//引入命名空间
using System;
using System.Drawing;
using System.Windows.Forms;

public class ProgressBars : Form
{
  ProgressBar pb;
  Label lbl;

  public ProgressBars()
  {
    Size = new Size(300,200);

    Button btn = new Button();
    btn.Parent = this;
    btn.Text = "&Start";
    btn.Location = new Point((Size.Width / 2) - (btn.Width / 2), (Size.Height / 4) - btn.Height);
    btn.Click += new EventHandler(btn_OnClick);

    lbl = new Label();
    lbl.Parent = this;
    lbl.Size = new Size(100,23);
    lbl.Location = new Point((Size.Width / 2) - (lbl.Width / 2), btn.Bottom + 25);
    lbl.BorderStyle = BorderStyle.FixedSingle;
    lbl.TextAlign = ContentAlignment.MiddleCenter;
    lbl.Text = "";

    pb = new ProgressBar();
    pb.Parent = this;
    pb.Location = new Point((Size.Width / 8), lbl.Bottom + 25);
    pb.Size = new Size((int)(Size.Width * 3 / 4), 20); 
    pb.Minimum = 0;
    pb.Maximum = 100;
  }

  private void btn_OnClick(object sender, EventArgs e)
  {
    pb.Value = 0;
    pb.Step = 1;
    for (int i = 0; i < 10; i++)
    {
      lbl.Text = i.ToString();
      pb.PerformStep();
      Application.DoEvents();
      System.Threading.Thread.Sleep(20);
    }
  }

  static void Main() 
  {
    Application.Run(new ProgressBars());
  }
}
开发者ID:C#程序员,项目名称:System.Windows.Forms,代码行数:54,代码来源:ProgressBar.Maximum


注:本文中的System.Windows.Forms.ProgressBar.Maximum属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。