ProgressBar.PerformStep メソッド
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim instance As ProgressBar instance.PerformStep


PerformStep メソッドは、プログレス バーの値を Step プロパティで指定した量だけインクリメントします。Step プロパティを使用すると、操作の完了したタスクごとにプログレス バーの値を変更する量を指定できます。たとえば、複数のファイルをコピーしている場合、Step プロパティの値は 1 に、Maximum プロパティの値はコピーするファイルの合計数に設定します。ファイルがコピーされるたびに、PerformStep メソッドを呼び出して、Step プロパティの値ずつプログレス バーをインクリメントできます。プログレス バーの値をさらに柔軟に制御する必要がある場合は、Increment メソッドを使用するか、Value プロパティの値を直接設定します。
Value プロパティは、ProgressBar の現在位置を指定します。PerformStep メソッドを呼び出した後で、Value プロパティが Maximum プロパティの値を超える場合、Value プロパティは Maximum プロパティの値のままになります。value パラメータに負の値を指定して PerformStep メソッドを呼び出した後に、Value プロパティが Minimum プロパティの値未満になった場合、Value プロパティは Minimum プロパティの値のままになります。

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

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からProgressBar.PerformStep メソッドを検索する場合は、下記のリンクをクリックしてください。

- ProgressBar.PerformStep メソッドのページへのリンク