ProgressBar.Maximum 속성

정의

컨트롤 범위의 최대값을 가져오거나 설정합니다.

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

속성 값

Int32

범위의 최대값입니다. 기본값은 100입니다.

예외

지정된 값이 0보다 작은 경우

예제

다음 코드 예제에서는 컨트롤을 ProgressBar 사용하여 파일 복사 작업의 진행률을 표시합니다. 이 예제에서는 속성 MinimumMaximum 속성을 사용하여 복사할 파일 수와 동일한 범위를 ProgressBar 지정합니다. 또한 코드는 메서드와 Step 함께 PerformStep 속성을 사용하여 파일이 복사될 때의 ProgressBar 값을 증분합니다. 이 예제에서는 ProgressBar 파일 복사 작업을 수행하는 호출 pBar1 Form 된 컨트롤을 만들고 파일 복사 작업이 성공적으로 완료되었음을 나타내는 부울 값을 반환하는 호출 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 속성입니다. 때 값을 Maximum 속성이 변경 되는 ProgressBar 컨트롤이 컨트롤의 새 범위에 맞게 다시 그려집니다. 때의 값을 Value 속성의 값은 Maximum 속성, 진행률 표시줄을 완전히으로 채워집니다.

이 속성을 사용 하 여 속성을 설정 해야 하는 값을 Value 지정할 수 있습니다 (속성을 설정 Value 하거나 메서드 PerformStep 를 사용 하 여Increment) 작업이 완료 되었음을 나타냅니다. 예를 들어,의 값을 설정할 수 있습니다는 Maximum 총 파일 복사 작업에서 파일에는 속성입니다. 파일을 복사 Value 할 때마다 총 파일 수가 복사될 때까지 속성을 1씩 늘릴 수 있습니다. 이때 진행률 표시줄 완전히 채울 수는 있습니다.

적용 대상

추가 정보