Click here to Skip to main content
15,896,063 members
Articles / Programming Languages / C#

TSmartProgressBar: A Smart C# ProgressBar with Percent Text

Rate me:
Please Sign up or sign in to vote.
3.68/5 (15 votes)
18 Sep 2008CPOL3 min read 91.4K   2.5K   29  
Customize a ProgressBar control with Label
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace CSUST.Data
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int delay = (int)numericUpDown1.Value;
            tProgressBar1.Value = 0;
            for (int k = 0; k <= 100; k++)
            {
                tProgressBar1.Value = k;
                System.Threading.Thread.Sleep(delay);
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            propertyGrid1.SelectedObject = tProgressBar1;

        }

        private void button2_Click_1(object sender, EventArgs e)
        {
            tProgressBar1.Value = 0;
        }

        private void label1_Click(object sender, EventArgs e)
        {
            CSUST.Data.TSmartProgressBar bar = new CSUST.Data.TSmartProgressBar();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            Type t = typeof(ProgressBar);
            MessageBox.Show(t.IsSealed.ToString());
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Instructor / Trainer CSUST
China China
College teacher and free programmer who expertises application sofwares for statistics reports,finance data handling,and MIS using Visual C#, Delphi, SQL, etc..

Comments and Discussions