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 하는 방법에 설명 합니다 메서드 및 Value 의 값을 ProgressBarTick 증가 하는 속성을 의 경우는 Timer합니다. 이 예제에서는 의 속성을 StatusBarPanel 표시 Value 하여 의 ProgressBar텍스트 표현을 제공합니다. 이 예제에서는 ProgressBar 라는 컨트롤과 StatusBar 라는 progressBar1가 포함된 컨트롤이 StatusBarPanelstatusBarPanel1있어야 합니다. 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 속성의 값 보다 큽니다.를 Maximum 속성을 Value 속성의 값으로 유지 됩니다는 Maximum 속성. 호출한 후는 Increment 에 지정 된 음수 값을 사용 하 여 메서드를 value 매개 변수를를 Value 속성의 값 보다 작습니다를 Minimum 속성인은 Value 속성을 의값으로유지됩니다Minimum속성입니다.

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

적용 대상

추가 정보