ProgressBar.Step 속성

정의

PerformStep() 메서드를 호출할 때 진행률 표시줄의 현재 위치를 증분시킬 크기를 가져오거나 설정합니다.

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

속성 값

Int32

PerformStep() 메서드를 호출할 때 진행률 표시줄이 증분되는 크기입니다. 기본값은 10입니다.

예제

다음 코드 예제에서는 컨트롤을 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

설명

사용할 수는 Step 작업에서 완료 된 각 태스크 진행률 표시줄의 값을 변경 하는 시간을 지정 하는 속성입니다. 예를 들어, 파일 그룹을 복사 하는 경우 하려는 값을 설정 합니다 Step 속성의 값과 1을는 Maximum 속성을 복사할 파일의 총 수입니다. 호출할 수 있습니다 각 파일이 복사 되는 경우는 PerformStep 값을 기준으로 진행률 표시줄을 증가 하는 방법의 Step 속성입니다. 사용할 수 있는 진행률 표시줄의 값 보다 유연 하 게 제어 하려는 경우는 Increment 메서드의 값을 가져오거나 설정 합니다 Value 속성을 직접.

적용 대상

추가 정보