다음을 통해 공유


ProgressBar.Increment(Int32) 메서드

정의

진행률 표시줄의 현재 위치를 지정된 양만큼 앞으로 이동합니다.

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

매개 변수

value
Int32

진행률 표시줄의 현재 위치를 증분할 크기입니다.

예외

속성이 Style 다음으로 설정됩니다. Marquee

예제

다음 코드 예제에서는 메서드와 속성을 사용 하 여 Increment 경우에 a ProgressBarTick 의 값을 증가 하는 방법을 보여 줍니다Timer.Value 또한 이 예제 Value 에서는 속성을 StatusBarPanel 표시하여 텍스트 표현 ProgressBar을 제공합니다. 이 예제에서는 명명된 ProgressBar 컨트롤과 StatusBar 명명progressBar1statusBarPanel1된 컨트롤이 있어야 합니다StatusBarPanel. Timer이름이 이time면 폼에 멤버로 추가해야 합니다.

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 메서드를 사용하면 진행률 표시줄의 값을 특정 크기만큼 증분할 수 있습니다. 진행률 표시줄을 증가시키는 이 메서드는 메서드와 Step 함께 PerformStep 속성을 사용하는 것과 유사합니다. 속성의 Value 현재 위치를 ProgressBar지정합니다. 메서드를 호출한 Increment 후 속성이 Value 속성 ValueMaximum 보다 크면 속성은 속성 값으로 Maximum 유지됩니다. 매개 변수에 지정된 음수 Increment 값을 사용하여 메서드를 호출한 후 속성이 속성 ValueMinimum 보다 작으면 속성은 속성 값으로 Minimum 유지됩니다.valueValue

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

적용 대상

추가 정보