ProgressBar.Minimum 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置控件范围的最小值。
public:
property int Minimum { int get(); void set(int value); };
public int Minimum { get; set; }
member this.Minimum : int with get, set
Public Property Minimum As Integer
属性值
范围的最小值。 默认值为 0。
例外
为该属性指定的值小于 0。
示例
下面的代码示例使用 ProgressBar 控件显示文件复制操作的进度。 该示例使用 Minimum 和 Maximum 属性为等效于要复制的文件数指定范围 ProgressBar 。 该代码还使用 Step 具有方法的属性 PerformStep 来递增复制文件时的值 ProgressBar 。 此示例要求你创建pBar1
一个名为在一Form个中创建的控件,并且有一个ProgressBar称为CopyFile
(创建的方法,该方法返回一个布尔值,该值指示文件复制操作已成功完成,) 执行文件复制操作。 该代码还要求创建包含要复制的文件的字符串数组,并将其传递到 CopyWithProgress
示例中定义的方法,并且该方法是从该示例中的另一个方法或事件调用的 Form。
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.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 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
注解
此属性指定属性的 Value 下限。 更改属性的值 Minimum 时,将 ProgressBar 重新绘制控件以反映控件的新范围。 当属性的值等于属性的值ValueMinimum时,进度栏为空。 若要更改进度栏的值, Step 请将属性与方法一起使用 PerformStep ,使用 Increment 该方法或直接设置属性的值 Value 。