C # How to Implement the dual progress bar function in winform,

Source: Internet
Author: User

C # How to Implement the dual progress bar function in winform,

The progress bar prompts the user (we) about the status of the software being installed-percentage. When the installation software is too large, a progress bar prompt will appear very slow, then we can use two progress bars prompt. Displays the current progress and the overall progress. So how can this function be implemented? I would like to introduce the basic methods here and hope to help programmers and learn from them.

Open Microsoft Visual Studio 2010:

1. Create a solution

2. Add a new form-progress bar exercise

Form Layout

(1) Controls

There are 6 lable labels, 2 Progress bars, 1 button control, and 2 textbox Control;

(2) Basic Attributes

Lable label: Lbl_1; lbl_2; lbl_3; lbl_4; lbl_5; lbl_6;

Text: % overall progress of the current progress

Lbl_7 (used by the author to show examples)

Progressbar control: Pgb_1; pgb_2

Button Control: Text: installation!

TextBox Control: Txtb_1; txtb_2

Progress bar 1 Property settings

# Maximum: 500

Minimum: 1

Value: 1

Progress bar 2 Property settings

# Maximum: 100

Minimum: 1

Value: 1

Button Control click Event code

Progress bar 1 -- accumulate 500 times in a loop

(Note: add the "Application. DoEvents ();" statement)

Button Control click Event code

Progress bar 2 -- accumulate 100 times in a loop

(Note: add the "Application. DoEvents ();" statement)

Complete code

Namespace Design

{

Public partial class form2: Form

{

Public form2 ()

{

InitializeComponent ();

}

 

Private void btn_count_Click (object sender, EventArgs e)

{

For (int k = 1; k <= 100; k ++)

{

// Current progress

For (int I = 1; I <= 500; I ++)

{

Txtb_show_1.Text = I. ToString ();

Application. DoEvents ();

This. pgb_1.Value = I;

This. lbl_1.Text = (I/5). ToString ();

}

// Overall progress

Txtb_show_2.Text = k. ToString ();

Application. DoEvents ();

This. pgb_2.Value = k;

This. lbl_3.Text = k. ToString ();

}

}

}

}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.