다음을 통해 공유


ProgressBar.PerformStep 메서드

정의

진행률 표시줄의 현재 위치를 속성 크기 Step 만큼 앞으로 이동합니다.

public:
 void PerformStep();
public void PerformStep();
member this.PerformStep : unit -> unit
Public Sub PerformStep ()

예외

StyleMarquee로 설정됩니다.

예제

다음 코드 예제에서는 컨트롤을 ProgressBar 사용하여 파일 복사 작업의 진행률을 표시합니다. 이 예제에서는 및 Maximum 속성을 사용하여 Minimum 복사할 파일 수와 동일한 범위를 ProgressBar 지정합니다. 또한 이 코드는 메서드와 StepPerformStep 함께 속성을 사용하여 파일이 복사될 때의 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 ] ))
         {
            // 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

설명

이 메서드는 PerformStep 속성에 지정된 양만큼 진행률 표시줄의 값을 증분합니다 Step . 이 Step 속성을 사용하여 작업에서 완료된 각 작업이 진행률 표시줄의 값을 변경하는 양을 지정할 수 있습니다. 예를 들어 파일 그룹을 복사하는 경우 속성 값을 Step 1로 설정하고 속성 값을 Maximum 복사할 총 파일 수로 설정할 수 있습니다. 각 파일이 복사되면 메서드를 PerformStep 호출하여 속성 값 Step 으로 진행률 표시줄을 증분할 수 있습니다. 진행률 표시줄의 값을 보다 유연하게 제어하려면 메서드를 Increment 사용하거나 속성 값을 Value 직접 설정할 수 있습니다.

속성의 Value 현재 위치를 ProgressBar지정합니다. 메서드를 호출한 PerformStep 후 속성이 Value 속성 ValueMaximum 보다 크면 속성은 속성 값으로 Maximum 유지됩니다. 지정된 음수 PerformStep 값을 사용하여 메서드를 호출한 StepValue 후 속성이 속성 ValueMinimum 보다 작으면 속성은 속성 값으로 Minimum 유지됩니다.

ProgressBar 스타일이 그 대신 Value연속 스크롤 막대를 표시하도록 Marquee 설정된 개체이므로 호출 PerformStep 이 필요하지 않으며 발생합니다InvalidOperationException.

적용 대상

추가 정보