ProgressBar.Increment(Int32) メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
指定した量だけプログレス バーの現在位置を進めます。
public:
void Increment(int value);
public void Increment (int value);
member this.Increment : int -> unit
Public Sub Increment (value As Integer)
パラメーター
- value
- Int32
プログレス バーの現在位置をインクリメントする量。
例外
例
次のコード例では、 メソッドと プロパティを Increment 使用して、 Value が発生した場合に の ProgressBar 値をインクリメントする Tick 方法を Timer示します。 この例では、 に StatusBarPanel プロパティをValue表示して、 のテキスト表現をProgressBar提供します。 この例では、 という名前のProgressBarコントロールと、 という名前progressBar1
の StatusBar を含むStatusBarPanelstatusBarPanel1
コントロールが必要です。 という名前time
の Timerは、メンバーとしてフォームに追加する必要があります。
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 です。 パラメーターにvalue
負の値を指定して Increment メソッドを呼び出した後、Valueプロパティが プロパティのMinimum値より小さい場合、Valueプロパティは プロパティの値のままMinimumです。
ProgressBarスタイルが にMarquee設定されているオブジェクトでは、 の代わりにValue継続的にスクロール するバーが表示されるため、 を呼び出すIncrement必要は不要であり、 がInvalidOperationException発生します。
適用対象
こちらもご覧ください
.NET
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示