ProgressBar クラスとは? わかりやすく解説

ProgressBar クラス

Windows プログレス バー コントロール表します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public Class ProgressBar
    Inherits Control
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] 
[ComVisibleAttribute(true)] 
public class ProgressBar : Control
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] 
[ComVisibleAttribute(true)] 
public ref class ProgressBar : public
 Control
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
/** @attribute ComVisibleAttribute(true) */ 
public class ProgressBar extends Control
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) 
ComVisibleAttribute(true) 
public class ProgressBar extends
 Control
解説解説

ProgressBar コントロールは、次の 3 つのスタイルうちいずれかを使用して時間のかかる操作進行状況視覚的に示します

Style プロパティは、表示される ProgressBarスタイル決定しますProgressBar コントロール向き水平方向にのみ設定できますProgressBar を垂直方向に作成する方法例については、ProgressBarRenderer クラストピック参照してくださいProgressBar コントロールは、通常アプリケーションファイルコピードキュメント印刷などのタスク実行するときに使用されます。視覚的な手掛かりがないと、アプリケーションユーザーは、アプリケーションから応答がないと判断する場合ありますアプリケーションProgressBar使用することにより、そのアプリケーション時間のかかるタスク実行中であり、まだ応答中であることをユーザー警告します。

Maximum プロパティおよび Minimum プロパティは、タスク進行状況を表す値の範囲定義しますMinimum プロパティは、通常は値 0 に設定されMaximum プロパティは、通常タスク完了を示す値に設定されます。たとえば、複数ファイルコピーする場合に、進行状況適切に表示するには、Maximum プロパティコピーされるファイル合計数に設定できます

Value プロパティは、操作完了向かってアプリケーションがどこまで進行したかを表しますProgressBar表示される値は、Value プロパティ現在の値の近似値にすぎません。Value プロパティは、ProgressBarサイズ基準として、次のブロック表示したり、バーサイズ増やしたりするタイミング決定します

ProgressBar によって表示される値を変更するには、Value プロパティ直接変更する方法の他に、いくつかの方法ありますStep プロパティ使用すると、Value プロパティインクリメントする特定の値指定してから、PerformStep メソッド呼び出して値をインクリメントできますインクリメント値を変更するには、Increment メソッド使用してValue プロパティインクリメントするために使用する値を指定します

使用例使用例

ProgressBar コントロール使用してファイルコピー操作進行状況表示するコード例次に示します。この例では、Minimum プロパティおよび Maximum プロパティ使用してコピーするファイル数に相当する ProgressBar範囲指定してます。このコードでは、ファイルコピー時に ProgressBar の値をインクリメントするために、PerformStep メソッドStep プロパティ使用します。この例では、Form 内に pBar1 という ProgressBar コントロール作成されており、ファイルコピー操作実行し操作正常終了したことを示すブール値を返す CopyFile というメソッド作成されている必要がありますまた、コピー対象ファイルを含む文字列配列作成され、この例の中で定義されている CopyWithProgress メソッドにその配列渡されており、そのメソッドForm別のメソッドまたはイベントから呼び出される必要もあります

Private Sub CopyWithProgress(ByVal
 ParamArray filenames As String())
    ' Display the ProgressBar control.
    pBar1.Visible = True
    ' Set Minimum to 1 to represent the first file being copied.
    pBar1.Minimum = 1
    ' Set Maximum to the total number of files to copy.
    pBar1.Maximum = filenames.Length
    ' Set the initial value of the ProgressBar.
    pBar1.Value = 1
    ' Set the Step property to a value of 1 to represent each file being
 copied.
    pBar1.Step = 1

    ' Loop through all files to copy.
    Dim x As Integer
    for x = 1 To filenames.Length - 1
        ' Copy the file and increment the ProgressBar if successful.
        If CopyFile(filenames(x - 1)) = True
 Then
            ' Perform the increment on the ProgressBar.
            pBar1.PerformStep()
        End If
    Next x
End Sub
private void CopyWithProgress(string[]
 filenames)
{
    // Display the ProgressBar control.
    pBar1.Visible = true;
    // Set Minimum to 1 to represent the first file being copied.
    pBar1.Minimum = 1;
    // Set Maximum to the total number of files to copy.
    pBar1.Maximum = filenames.Length;
    // Set the initial value of the ProgressBar.
    pBar1.Value = 1;
    // Set the Step property to a value of 1 to represent each file
 being copied.
    pBar1.Step = 1;
    
    // Loop through all files to copy.
    for (int x = 1; x <= filenames.Length;
 x++)
    {
        // Copy the file and increment the ProgressBar if successful.
        if(CopyFile(filenames[x-1]) == true)
        {
            // Perform the increment on the ProgressBar.
            pBar1.PerformStep();
        }
    }
}
private:
   void CopyWithProgress( array<String^>^filenames )
   {
      // Display the ProgressBar control.
      pBar1->Visible = true;

      // Set Minimum to 1 to represent the first file being copied.
      pBar1->Minimum = 1;

      // Set Maximum to the total number of files to copy.
      pBar1->Maximum = filenames->Length;

      // Set the initial value of the ProgressBar.
      pBar1->Value = 1;

      // Set the Step property to a value of 1 to represent each file
 being copied.
      pBar1->Step = 1;

      // Loop through all files to copy.
      for ( int x = 1; x <= filenames->Length;
 x++ )
      {
         // Copy the file and increment the ProgressBar if successful.
         if ( CopyFile( filenames[ x - 1 ] ) == true
 )
         {
            // Perform the increment on the ProgressBar.
            pBar1->PerformStep();
         }
      }
   }
private void CopyWithProgress(String fileNames[])
{
    // Display the ProgressBar control.
    pBar1.set_Visible(true);
    // Set Minimum to 1 to represent the first file being copied.
    pBar1.set_Minimum(1);
    // Set Maximum to the total number of files to copy.
    pBar1.set_Maximum(fileNames.get_Length());
    // Set the initial value of the ProgressBar.
    pBar1.set_Value(1);
    // Set the Step property to a value of 1 to represent each file
    // being copied.
    pBar1.set_Step(1);
    // Loop through all files to copy.
    for (int x = 1; x <= fileNames.get_Length();
 x++) {
        // Copy the file and increment the ProgressBar if successful.
        if (CopyFile(fileNames[(x - 1)]) == true)
 {
            // Perform the increment on the ProgressBar.
            pBar1.PerformStep();
        }
    }
} //CopyWithProgress
継承階層継承階層
System.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
       System.Windows.Forms.Control
        System.Windows.Forms.ProgressBar
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「ProgressBar クラス」の関連用語

ProgressBar クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ProgressBar クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS