Assembly : System.Windows.Forms (dans system.windows.forms.dll)
SyntaxePublic Property Step As Integer
Dim instance As ProgressBar Dim value As Integer value = instance.Step instance.Step = value
public int Step { get; set; }
public: property int Step { int get (); void set (int value); }
/** @property */ public int get_Step () /** @property */ public void set_Step (int value)
public function get Step () : int public function set Step (value : int)
Valeur de la propriété
La quantité d'incrémentation de la barre de progression à chaque appel à la méthode PerformStep. La valeur par défaut est 10.
NotesVous pouvez utiliser la propriété Step pour spécifier la modification de la valeur de la barre de progression entraînée par chaque tâche achevée. Par exemple, si vous copiez un groupe de fichiers, il se peut que vous vouliez attribuer la valeur 1 à la propriété Step et le nombre total de fichiers à copier comme valeur de la propriété Maximum. Lors de la copie de chaque fichier, vous pouvez appeler la méthode PerformStep pour incrémenter la barre de progression de la valeur de la propriété Step. Si vous voulez disposer d'un contrôle plus souple de la valeur de la barre de progression, vous pouvez utiliser la méthode Increment ou définir directement la valeur de la propriété Value.
ExempleL'exemple de code suivant utilise un contrôle ProgressBar pour afficher la progression d'une opération de copie d'un fichier. L'exemple utilise les propriétés Minimum et Maximum pour spécifier pour ProgressBar une plage équivalente au nombre de fichiers à copier. Le code utilise aussi la propriété Step avec la méthode PerformStep pour incrémenter la valeur de ProgressBar chaque fois qu'un fichier est copié. Cet exemple suppose que vous avez créé un contrôle ProgressBar nommé pBar1 dans Form et une méthode nommée CopyFile (qui retourne une valeur Boolean indiquant que la copie du fichier s'est achevée avec succès) qui effectue l'opération de copie des fichiers. Le code suppose également qu'un tableau de chaînes contenant les fichiers à copier est créé et passé à la méthode CopyWithProgress définie dans l'exemple et que la méthode est appelée à partir d'une autre méthode ou d'un autre événement dans 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
Plates-formesWindows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile pour Pocket PC, Windows Mobile pour Smartphone, Windows Server 2003, Windows XP Édition Media Center, Windows XP Professionnel Édition x64, Windows XP SP2, Windows XP Starter Edition
Le .NET Framework ne prend pas en charge toutes les versions de chaque plate-forme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise.
Outils (masquer)
S'enregistrer
Liste des Membres
Qui est en ligne?
FAQ