ProgressBar.Step Tulajdonság

Definíció

Lekéri vagy beállítja azt az összeget, amellyel a PerformStep() metódus hívása növeli az állapotsor aktuális pozícióját.

public:
 property int Step { int get(); void set(int value); };
public int Step { get; set; }
member this.Step : int with get, set
Public Property Step As Integer

Tulajdonság értéke

Az az összeg, amellyel a folyamatjelző sávot a metódus minden egyes hívásával növelni kell PerformStep() . Az alapértelmezett érték 10.

Példák

Az alábbi példakód egy vezérlővel ProgressBar jeleníti meg a fájlmásolási művelet előrehaladását. A példa a Minimum tulajdonságokat használva Maximum a másolandó fájlok számával egyenértékű tartományt ProgressBar ad meg. A kód a Step tulajdonságot is használja a PerformStep metódussal a fájl másolásának értékének ProgressBar növeléséhez. Ehhez a példához létre kell hoznia egy ProgressBar vezérlőelemet, amely egy, a Formfájlmásolási műveletet végrehajtó metódust hoz létre pBar1CopyFile (amely egy logikai értéket ad vissza, amely azt jelzi, hogy a fájlmásolási művelet sikeresen befejeződött). A kódhoz emellett létre kell hoznia és továbbítania CopyWithProgress kell a példában meghatározott metódusnak a másolandó fájlokat tartalmazó sztringekből álló tömböt, és a metódust egy másik metódusból vagy eseményből kell meghívni a Formpéldában.

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

Megjegyzések

A tulajdonság használatával Step megadhatja, hogy egy művelet egyes befejezett tevékenységei milyen mértékben módosítják a folyamatjelző sáv értékét. Ha például egy fájlcsoportot másol, érdemes lehet a tulajdonság értékét Step 1 értékre állítani, a Maximum tulajdonság értékét pedig a másolandó fájlok teljes számára. Az egyes fájlok másolásakor meghívhatja a metódust, PerformStep hogy a tulajdonság értékével növelje a folyamatjelző sávot Step . Ha rugalmasabban szeretné szabályozni a folyamatjelző sáv értékét, használhatja a Increment metódust, vagy beállíthatja közvetlenül a Value tulajdonság értékét.

A következőre érvényes:

Lásd még