Assembly : System.Windows.Forms (dans system.windows.forms.dll)
SyntaxePublic Sub Increment ( _ value As Integer _ )
Dim instance As ProgressBar Dim value As Integer instance.Increment(value)
public void Increment ( int value )
public: void Increment ( int value )
public void Increment ( int value )
public function Increment ( value : int )
Paramètres
- value
Quantité d'incrémentation de la position actuelle de la barre de progression.
NotesLa méthode Increment vous permet d'incrémenter la valeur de la barre de progression d'une quantité spécifique. Cette méthode d'incrémentation de la barre de progression est analogue à l'utilisation de la propriété Step avec la méthode PerformStep. La propriété Value spécifie la position actuelle de ProgressBar. Si, après l'appel la méthode Increment, la propriété Value est supérieure à la valeur de la propriété Maximum, la valeur attribuée à la propriété Value reste celle de la propriété Maximum. Si, après l'appel à la méthode Increment avec une valeur négative spécifiée dans le paramètre value, la propriété Value est inférieure à la valeur de la propriété Minimum, la valeur attribuée à la propriété Value reste celle de la propriété Minimum.
ExempleL'exemple de code suivant illustre comment utiliser la méthode Increment et la propriété Value pour incrémenter la valeur de ProgressBar dans l'événement Tick de Timer. L'exemple affiche également la propriété Value dans StatusBarPanel afin de fournir une représentation textuelle de ProgressBar. Cet exemple suppose que vous disposez d'un contrôle ProgressBar, nommé progressBar1 et un contrôle StatusBar qui contient StatusBarPanel, nommé statusBarPanel1. Timer, nommé time, doit être ajouté au formulaire en tant que membre.
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
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: 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.set_Interval(250); // Connect the Tick event of the timer to its event handler. time.add_Tick(new EventHandler(IncreaseProgressBar)); // Start the timer. time.Start(); } //InitializeMyTimer 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.set_Text(progressBar1.get_Value() + "% Completed"); // Determine if we have completed by comparing the value of the Value // property to the Maximum value. if (progressBar1.get_Value() == progressBar1.get_Maximum()) { // Stop the timer. time.Stop(); } } //IncreaseProgressBar
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