ProgressBarの値を進捗させるにはPerformStepメソッドを使用します。
PerformStepメソッド実行時の進捗量はPerfomStepプロパティに設定しておきます。
下記は、ProgressBarの値をを進捗させる例です。
[Do Something]ボタンがクリックされると値を進捗します。
VBの例
' [Do Something]ボタンクリック時の処理 Private Sub btnDoSomething_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDoSomething.Click 'プログレスバーの値を初期化 ProgressBar1.Value = 0 '★★★値の進捗量を設定★★★ ProgressBar1.Step = 1 For I As Integer = 1 To 100 Application.DoEvents() '200mSec スリープ System.Threading.Thread.Sleep(200) '★★★値を進捗させる★★★ ProgressBar1.PerformStep() Next End Sub
C#の例
// [Do Something]ボタンクリック時の処理 private void btnDoSomething_Click(object sender, EventArgs e) { // プログレスバーの値を初期化 progressBar1.Value = 0; // ★★★値の進捗量を設定★★★ progressBar1.Step = 1; for ( int i = 0; i < 100; i++ ) { Application.DoEvents(); // 200mSec スリープ System.Threading.Thread.Sleep(200); // ★★★値を進捗させる★★★ progressBar1.PerformStep(); } }
Please follow and like us:
コメント
[…] 値を進捗させる […]