Aracılığıyla paylaş


ProgressBar.Maximum Özellik

Tanım

Denetim aralığının en büyük değerini alır veya ayarlar.

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

Özellik Değeri

Aralığın en büyük değeri. Varsayılan değer 100'dür.

Özel durumlar

Belirtilen değer 0'dan küçük.

Örnekler

Aşağıdaki kod örneği, bir ProgressBar dosya kopyalama işleminin ilerleme durumunu görüntülemek için bir denetim kullanır. Örnek, kopyalanacak dosya sayısına eşdeğer bir aralık belirtmek için ProgressBar ve Maximum özelliklerini kullanırMinimum. Kod, dosyasının Step kopyalandığında değerini ProgressBar artırmak için yöntemiyle özelliğini PerformStep de kullanır. Bu örnek, içinde oluşturulan Form adlı pBar1 bir ProgressBar denetimin oluşturulmasını ve dosya kopyalama işlemini gerçekleştiren (dosya kopyalama işleminin başarıyla tamamlandığını gösteren boole değeri döndüren) adlı CopyFile bir yöntem oluşturulmasını gerektirir. Kod ayrıca kopyalanacak dosyaları içeren bir dizi dizenin oluşturulmasını ve örnekte tanımlanan yönteme geçirilmesini CopyWithProgress ve yönteminin içinde başka bir yöntemden veya olaydan çağrıldığını Formgerektirir.

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

Açıklamalar

Bu özellik özelliğin üst sınırını Value belirtir. Özelliğin Maximum değeri değiştirildiğinde, denetimin ProgressBar yeni aralığını yansıtacak şekilde yeniden çizilir. Özelliğin Value değeri özelliğin değerine Maximum eşit olduğunda ilerleme çubuğu tamamen doldurulur.

Bir işlemin tamamlandığını belirtmek için özelliğin Value ayarlanması gereken bir değer belirtmek için (özelliği ayarlayarak Value veya veya PerformStep yöntemlerini kullanarakIncrement) bu özelliği kullanabilirsiniz. Örneğin, özelliğinin Maximum değerini bir dosya kopyalama işlemindeki toplam dosya sayısına ayarlayabilirsiniz. Bir dosya her kopyalandığında, toplam dosya sayısı kopyalanana Value kadar özellik 1 artırılabilir. Bu noktada ilerleme çubuğu tamamen doldurulur.

Şunlara uygulanır

Ayrıca bkz.