ProgressBar.Minimum Eigenschap

Definitie

Hiermee haalt u de minimumwaarde van het bereik van het besturingselement op of stelt u deze in.

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

Waarde van eigenschap

De minimumwaarde van het bereik. De standaardwaarde is 0.

Uitzonderingen

De opgegeven waarde voor de eigenschap is kleiner dan 0.

Voorbeelden

In het volgende codevoorbeeld wordt een ProgressBar besturingselement gebruikt om de voortgang van een bestandskopiebewerking weer te geven. In het voorbeeld worden de Minimum en Maximum eigenschappen gebruikt om een bereik op te geven dat ProgressBar gelijk is aan het aantal bestanden dat moet worden gekopieerd. De code maakt ook gebruik van de Step eigenschap met de PerformStep methode om de waarde van het ProgressBar bestand te verhogen als een bestand wordt gekopieerd. Voor dit voorbeeld is vereist dat u een ProgressBar besturingselement hebt gemaakt pBar1 dat is gemaakt in een Form, en dat er een methode is gemaakt met de naam CopyFile (die een Booleaanse waarde retourneert die aangeeft dat de bewerking voor het kopiëren van bestanden is voltooid) waarmee de bewerking voor het kopiëren van bestanden wordt uitgevoerd. De code vereist ook dat een matrix met tekenreeksen met de te kopiëren bestanden wordt gemaakt en doorgegeven aan de CopyWithProgress methode die in het voorbeeld is gedefinieerd, en dat de methode wordt aangeroepen vanuit een andere methode of gebeurtenis in de 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

Opmerkingen

Met deze eigenschap geeft u de ondergrens van de Value eigenschap op. Wanneer de waarde van de Minimum eigenschap wordt gewijzigd, wordt het ProgressBar besturingselement opnieuw getekend om het nieuwe bereik van het besturingselement weer te geven. Wanneer de waarde van de Value eigenschap gelijk is aan de waarde van de Minimum eigenschap, is de voortgangsbalk leeg. Als u de waarde van de voortgangsbalk wilt wijzigen, gebruikt u de Step eigenschap met de PerformStep methode, gebruikt u de Increment methode of stelt u de waarde van de Value eigenschap rechtstreeks in.

Van toepassing op

Zie ook