ProgressBar.Minimum Egenskap
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Hämtar eller anger minimivärdet för kontrollens intervall.
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
Egenskapsvärde
Minimivärdet för intervallet. Standardvärdet är 0.
Undantag
Värdet som anges för egenskapen är mindre än 0.
Exempel
I följande kodexempel används en ProgressBar kontroll för att visa förloppet för en filkopieringsåtgärd. I exemplet används Minimum egenskaperna och Maximum för att ange ett intervall för ProgressBar det som motsvarar antalet filer som ska kopieras. Koden använder Step också egenskapen med PerformStep metoden för att öka värdet för som ProgressBar en fil kopieras. Det här exemplet kräver att du har en ProgressBar kontroll som skapats med namnet pBar1 som skapas i en Form, och att det finns en metod som skapats med namnet CopyFile (som returnerar ett booleskt värde som anger att filkopieringsåtgärden har slutförts) som utför filkopieringsåtgärden. Koden kräver också att en matris med strängar som innehåller filerna som ska kopieras skapas och skickas till den CopyWithProgress metod som definieras i exemplet och att metoden anropas från en annan metod eller händelse i 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 ] ))
{
// 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]))
{
// 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
Kommentarer
Den här egenskapen anger den nedre gränsen för Value egenskapen. När värdet för Minimum egenskapen ändras ProgressBar ritas kontrollen om för att återspegla kontrollens nya intervall. När värdet för Value egenskapen är lika med värdet för Minimum egenskapen är förloppsindikatorn tom. Om du vill ändra värdet för förloppsindikatorn använder du Step egenskapen med PerformStep metoden, använder Increment metoden eller anger värdet för Value egenskapen direkt.