Share via


ProgressBar.Increment(Int32) Yöntem

Tanım

İlerleme çubuğunun geçerli konumunu belirtilen tutara kadar ilerletir.

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

Parametreler

value
Int32

İlerleme çubuğunun geçerli konumunu artırma miktarı.

Özel durumlar

Style özelliği Marquee olarak ayarlanmıştır

Örnekler

Aşağıdaki kod örneği, bir durumunda değerini artırmak için yönteminin ve Value özelliğinin ProgressBarTimerTick nasıl kullanılacağını Increment gösterir. Örnek ayrıca içinde özelliğini StatusBarPanel görüntülüyor Value ve bunun metinsel bir gösterimini ProgressBarsağlıyor. Bu örnek, adlı bir ProgressBar denetiminiz ve adlı progressBar1bir StatusBar içeren statusBarPanel1bir StatusBarPaneldenetiminiz olmasını gerektirir. Timeradlı time, forma üye olarak eklenmelidir.

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

Açıklamalar

yöntemi, Increment ilerleme çubuğu değerini belirli bir miktar artırmanıza olanak tanır. İlerleme çubuğunu artırmanın bu yöntemi, yöntemiyle PerformStep özelliğini kullanmaya Step benzer. özelliği geçerli Value konumunu ProgressBarbelirtir. yöntemi çağrıldıktan Increment sonra özelliği özelliğin değerinden Maximum büyükse, Value özellik özelliğin Maximum değerinde Value kalır. parametresinde Incrementvalue belirtilen negatif bir değerle yöntemini çağırdıktan sonra özelliği Value özelliğin değerinden Minimum küçükse, Value özellik özelliğin Minimum değerinde kalır.

stili yerine sürekli kaydırma çubuğu Valuegörüntüleyecek şekilde ayarlanmış Marquee bir ProgressBar nesnenin çağrısı Increment gereksiz olduğundan ve bir InvalidOperationExceptionoluşturur.

Şunlara uygulanır

Ayrıca bkz.