Assembly : System.Windows.Forms (dans system.windows.forms.dll)
Syntaxe<BindableAttribute(True)> _ Public Property Value As Integer
Dim instance As ProgressBar Dim value As Integer value = instance.Value instance.Value = value
[BindableAttribute(true)] public int Value { get; set; }
[BindableAttribute(true)] public: property int Value { int get (); void set (int value); }
/** @property */ public int get_Value () /** @property */ public void set_Value (int value)
public function get Value () : int public function set Value (value : int)
Valeur de la propriété
Position dans la plage de la barre de progression. La valeur par défaut est 0.
Exceptions
NotesLes valeurs minimale et maximale de la propriété Value sont spécifiées par les propriétés Minimum et Maximum. La propriété vous permet d'incrémenter ou de décrémenter directement la valeur de la barre de progression. Pour effectuer des augmentations constantes de la valeur du contrôle ProgressBar vous pouvez utiliser la propriété Step avec la méthode PerformStep. Pour augmenter la valeur de la barre de progression de quantités variables, utilisez la méthode Increment.
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.
Informations de version
Outils (masquer)
S'enregistrer
Liste des Membres
Qui est en ligne?
FAQ