ProgressBar.Increment(Int32) ProgressBar.Increment(Int32) ProgressBar.Increment(Int32) ProgressBar.Increment(Int32) Method

정의

진행률 표시줄의 현재 위치를 지정된 크기만큼 진행합니다.Advances the current position of the progress bar by the specified amount.

public:
 void Increment(int value);
public void Increment (int value);
member this.Increment : int -> unit
Public Sub Increment (value As Integer)

매개 변수

value
Int32 Int32 Int32 Int32

진행률 표시줄의 현재 위치를 증분시킬 크기입니다.The amount by which to increment the progress bar's current position.

예외

예제

다음 코드 예제에 사용 하는 방법을 보여 줍니다.는 Increment 메서드 및 Value 속성의 값을 증분을 ProgressBarTick 의 이벤트를 Timer.The following code example demonstrates how to use the Increment method and the Value property to increment the value of a ProgressBar in the Tick event of a Timer. 표시 합니다는 Value 에서 속성을 StatusBarPanel 의 텍스트 표현을 제공 하는 ProgressBar합니다.The example also displays the Value property in a StatusBarPanel to provide a textual representation of the ProgressBar. 이 예제를 실행 하려면를 ProgressBar 라는 컨트롤 progressBar1, 및 StatusBar 포함 된 컨트롤을 StatusBarPanel명명 된 statusBarPanel1합니다.This example requires that you have a ProgressBar control, named progressBar1, and a StatusBar control that contains a StatusBarPanel, named statusBarPanel1. 합니다 Timer명명 된 time를 구성원으로 폼에 추가 해야 합니다.The Timer, named time, must be added to the form as a member.

private:
   Timer^ time;

   // Call this method from the constructor of the form.
   void InitializeMyTimer()
   {
      // Set the interval for the timer.
      time->Interval = 250;

      // Connect the Tick event of the timer to its event handler.
      time->Tick += gcnew EventHandler( this, &Form1::IncreaseProgressBar );

      // Start the timer.
      time->Start();
   }

   void IncreaseProgressBar( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      // Increment the value of the ProgressBar a value of one each time.
      progressBar1->Increment( 1 );

      // Display the textual value of the ProgressBar in the StatusBar control's first panel.
      statusBarPanel1->Text = String::Concat( progressBar1->Value, "% Completed" );

      // Determine if we have completed by comparing the value of the Value property to the Maximum value.
      if ( progressBar1->Value == progressBar1->Maximum )

      // Stop the timer.
      time->Stop();
   }
private Timer time = new Timer();

// Call this method from the constructor of the form.
private void InitializeMyTimer()
{
   // Set the interval for the timer.
   time.Interval = 250;
   // Connect the Tick event of the timer to its event handler.
   time.Tick += new EventHandler(IncreaseProgressBar);
   // Start the timer.
   time.Start();
}

private void IncreaseProgressBar(object sender, EventArgs e)
{
   // Increment the value of the ProgressBar a value of one each time.
   progressBar1.Increment(1);
   // Display the textual value of the ProgressBar in the StatusBar control's first panel.
   statusBarPanel1.Text = progressBar1.Value.ToString() + "% Completed";
   // Determine if we have completed by comparing the value of the Value property to the Maximum value.
   if (progressBar1.Value == progressBar1.Maximum)
      // Stop the timer.
      time.Stop();
}
Private time As New Timer()

' Call this method from the constructor of the form.
Private Sub InitializeMyTimer()
   ' Set the interval for the timer.
   time.Interval = 250
   ' Connect the Tick event of the timer to its event handler.
   AddHandler time.Tick, AddressOf IncreaseProgressBar
   ' Start the timer.
   time.Start()
End Sub


Private Sub IncreaseProgressBar(ByVal sender As Object, ByVal e As EventArgs)
   ' Increment the value of the ProgressBar a value of one each time.
   ProgressBar1.Increment(1)
   ' Display the textual value of the ProgressBar in the StatusBar control's first panel.
   statusBarPanel1.Text = ProgressBar1.Value.ToString() + "% Completed"
   ' Determine if we have completed by comparing the value of the Value property to the Maximum value.
   If ProgressBar1.Value = ProgressBar1.Maximum Then
      ' Stop the timer.
      time.Stop()
   End If
End Sub

설명

Increment 메서드를 사용 하면 진행률 표시줄의 값을 지정 된 크기 증가 합니다.The Increment method enables you to increment the value of the progress bar by a specific amount. 진행률 표시줄을 증분이 메서드를 사용 하 여 비슷합니다는 Step 속성을 PerformStep 메서드.This method of incrementing the progress bar is similar to using the Step property with the PerformStep method. 합니다 Value 속성의 현재 위치를 지정 된 ProgressBar합니다.The Value property specifies the current position of the ProgressBar. 호출한 후를 Increment 메서드를를 Value 속성의 값 보다 큽니다.를 Maximum 속성을 Value 속성의 값으로 유지 됩니다는 Maximum 속성.If, after calling the Increment method, the Value property is greater than the value of the Maximum property, the Value property remains at the value of the Maximum property. 호출한 후는 Increment 에 지정 된 음수 값을 사용 하 여 메서드를 value 매개 변수를를 Value 속성의 값 보다 작습니다를 Minimum 속성인은 Value 속성을 의값으로유지됩니다Minimum속성입니다.If, after calling the Increment method with a negative value specified in the value parameter, the Value property is less than the value of the Minimum property, the Value property remains at the value of the Minimum property.

때문에 ProgressBar 해당 스타일으로 설정 되어 개체 Marquee 대신 지속적으로 스크롤 막대를 표시 해당 Value를 호출 Increment 필요 하지 않으며 발생는 InvalidOperationException.Because a ProgressBar object whose style is set to Marquee displays a continuously scrolling bar instead of its Value, calling Increment is unnecessary and will raise an InvalidOperationException.

적용 대상

추가 정보