ProgressBar.Minimum 属性

获取或设置控件范围的最小值。

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
Public Property Minimum As Integer
用法
Dim instance As ProgressBar
Dim value As Integer

value = instance.Minimum

instance.Minimum = value
public int Minimum { get; set; }
public:
property int Minimum {
    int get ();
    void set (int value);
}
/** @property */
public int get_Minimum ()

/** @property */
public void set_Minimum (int value)
public function get Minimum () : int

public function set Minimum (value : int)

属性值

范围的最小值。默认值为 0。

异常

异常类型 条件

ArgumentException

为该属性指定的值小于 0。

备注

此属性指定 Value 属性的下限。当 Minimum 属性的值更改时,将重绘 ProgressBar 控件以反映该控件的新范围。当 Value 属性的值等于 Minimum 属性的值时,进度栏为空。若要更改进度栏的值,可将 Step 属性用于 PerformStep 方法、使用 Increment 方法或直接设置 Value 属性的值。

示例

下面的代码示例使用 ProgressBar 控件来显示文件复制操作的进度。该示例使用 MinimumMaximum 属性指定 ProgressBar 的范围,它等效于要复制的文件数。代码还将 Step 属性用于 PerformStep 方法以在复制文件时增加 ProgressBar 的值。此示例要求已在 Form 中创建了名为 pBar1ProgressBar 控件,并且还创建了执行文件复制操作的名为 CopyFile 的方法(它返回一个布尔值,指示文件复制操作已成功完成)。此段代码还要求已创建包含要复制的文件的字符串数组,并已将其传递给示例中定义的 CopyWithProgress 方法,而且要求从 Form 中的另一个方法或事件中调用该方法。

Private Sub CopyWithProgress(ByVal ParamArray filenames As String())
    ' 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.
    Dim x As Integer
    for x = 1 To filenames.Length - 1
        ' Copy the file and increment the ProgressBar if successful.
        If CopyFile(filenames(x - 1)) = True Then
            ' Perform the increment on the ProgressBar.
            pBar1.PerformStep()
        End If
    Next x
End Sub
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();
        }
    }
}
private:
   void CopyWithProgress( array<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();
         }
      }
   }
private void CopyWithProgress(String fileNames[])
{
    // Display the ProgressBar control.
    pBar1.set_Visible(true);
    // Set Minimum to 1 to represent the first file being copied.
    pBar1.set_Minimum(1);
    // Set Maximum to the total number of files to copy.
    pBar1.set_Maximum(fileNames.get_Length());
    // Set the initial value of the ProgressBar.
    pBar1.set_Value(1);
    // Set the Step property to a value of 1 to represent each file
    // being copied.
    pBar1.set_Step(1);
    // Loop through all files to copy.
    for (int x = 1; x <= fileNames.get_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();
        }
    }
} //CopyWithProgress

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

ProgressBar 类
ProgressBar 成员
System.Windows.Forms 命名空间
ProgressBar.Maximum 属性
Value