A ProgressBar control is used to represent the progress of a lengthy operation that takes time where a user has to wait for the operation to be finished.

Here I used ProcessBar Dynamically.

using System;
using System.Windows.Forms;
namespace ProcessBar
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
         private void btnStart_Click(object sender, EventArgs e)
        {
            //creating a dynamic ProgressBar is to create an instance of ProgressBar class.
            ProgressBar pBar = new ProgressBar();
                 //name of process bar
            pBar.Name = "progressBar1";
             // set height and width of processbar
            pBar.Width = 200;
            pBar.Height = 20;
             //add the ProgressBar to a Form. 
            Controls.Add(pBar);
             //The Dock property is used to set the position of a ProgressBar
            pBar.Dock = DockStyle.Bottom;
             //The Minimum and Maximum properties define the range of a ProgressBar
            pBar.Minimum = 0;
            pBar.Maximum = 100;
             //The Value property represents the current value of a ProgressBar.
            pBar.Value = 70;
        }
    } }

Output

  Modified On Sep-18-2014 01:24:05 PM

Leave Comment