ProgressBar in C# : ProgressBar « GUI Windows Form « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Date Time
8.Design Patterns
9.Development Class
10.Event
11.File Stream
12.Generics
13.GUI Windows Form
14.Internationalization I18N
15.Language Basics
16.LINQ
17.Network
18.Office
19.Reflection
20.Regular Expressions
21.Security
22.Services Event
23.Thread
24.Web Services
25.Windows
26.Windows Presentation Foundation
27.XML
28.XML LINQ
C# / C Sharp » GUI Windows Form » ProgressBar 




ProgressBar in C#
ProgressBar in C#

// I am trying to use Class ProgressBar in C#
// Editor Used : Antechinus http://www.c-point.com
// Dt. 9th Jan. 2001 
// ... Special thanks Saurabh for help & guidance ... Thanks! someday i would 
//       do the way you do.... programming
// ... thanks Mahesh for loading my codes. Your site rules!
// ... thanks to you for reading it you know better who you are :)
// if you have any comments or doubts or whatever please don't 
// hesitate to e-mail me.

    using System;
    using System.Drawing;
    using System.ComponentModel;
    using System.Windows.Forms;

    /// <summary>
    ///    Summary description for Win32Form2.
    /// </summary>
    public class Win32Form2 : System.Windows.Forms.Form {

        /// <summary>
        ///    Required by the Win Forms designer
        /// </summary>
        private System.ComponentModel.Container components;
        private System.Windows.Forms.TextBox textBox1;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Button button1;
        private System.Windows.Forms.ProgressBar progressBar1;

        public Win32Form2() {
            // Required for Win Form Designer support
            InitializeComponent();
        }

        /// <summary>
        ///    The main entry point for the application.
        /// </summary>
        public static void Main(string[] args) {
            Application.Run(new Win32Form2());
        }

        /// <summary>
        ///    Required method for Designer support - do not modify
        ///    the contents of this method with an editor
        /// </summary>
        private void InitializeComponent() {
            this.components = new System.ComponentModel.Container();
            this.label1 = new System.Windows.Forms.Label();
            this.progressBar1 = new System.Windows.Forms.ProgressBar();
            this.button1 = new System.Windows.Forms.Button();
            this.textBox1 = new System.Windows.Forms.TextBox();
            
            //@design this.TrayHeight = 0;
            //@design this.TrayLargeIcon = false;
            //@design this.TrayAutoArrange = true;
            label1.Location = new System.Drawing.Point(3240);
            label1.Text = "Progress Value";
            label1.Size = new System.Drawing.Size(8824);
            label1.TabIndex = 2;
            
            progressBar1.Maximum = 10;
            progressBar1.Location = new System.Drawing.Point(8312);
            progressBar1.Minimum = 0;
            progressBar1.TabIndex = 0;
            progressBar1.Value = 0;
    
            //We have calculated the excat size which will result in only 20 boxes to be drawn
            
            progressBar1.Size = new System.Drawing.Size(52040);
            progressBar1.Step = 1;
            
            button1.Location = new System.Drawing.Point(152168);
            button1.Size = new System.Drawing.Size(14448);
            button1.TabIndex = 1;
            button1.Text = "button1";
            button1.Click += new System.EventHandler(button1_Click);
            
            textBox1.Location = new System.Drawing.Point(13640);
            textBox1.Text = "0";
            textBox1.TabIndex = 3;
            textBox1.Size = new System.Drawing.Size(18420);
            this.Text = "Win32Form2";
            this.AutoScaleBaseSize = new System.Drawing.Size(513);
            this.ClientSize = new System.Drawing.Size(616393);
            this.Click += new System.EventHandler(Win32Form2_Click);
            
            this.Controls.Add(textBox1);
            this.Controls.Add(label1);
            this.Controls.Add(button1);
            this.Controls.Add(progressBar1);
        }

        protected void button1_Click(object sender, System.EventArgs e) {
        
            //this checking is automatically done as stated in the Ref Documentation 
            //but it does not work , BUGssssss 
            //so we have to do it shhhhh .... 
            if (progressBar1.Value == progressBar1.Maximum){
                progressBar1.Value =  progressBar1.Minimum;
            }
            progressBar1.PerformStep();
            textBox1.Text=progressBar1.Value.ToString() // Displays the values of progressbar in textbox
    
        }
        protected void Win32Form2_Click(object sender, System.EventArgs e) {
        }
    }



           
       














Related examples in the same category
1.ProgressBar HostProgressBar Host
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.