- Sistema Operativo: Windows
- IDE: Visual Studio 2009, framework 4.0
Paso 1: Diseño interfaz
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Ejemplo_Progress_bar { public partial class Principal : Form { public Principal() { InitializeComponent(); } private void butLanzar_Click( object sender, EventArgs e) { // Reset progressBar1.Value = 0; progressBar1.Maximum = int .Parse(txtTiempo.Text); // Activamos el Timer timer1.Interval = 1000; // 1 Segundo timer1.Start(); } // Evento del timer private void timer1_Tick( object sender, EventArgs e) { // Comparamos si se ha llegado al limite if (progressBar1.Maximum == progressBar1.Value) { timer1.Stop(); MessageBox.Show( "Completado" ); } // Avanzamos el la barra progressBar1.Increment(1); } } } |
Resultado:
No hay comentarios:
Publicar un comentario