Solved

adding progress bar

Posted on 2011-09-25
2
372 Views
Last Modified: 2012-05-12
Hi

I have an a windows form application that use one class (its name is Parser)
this form has a button and when i click on the windows form application button it call one of the parser class method . this method simply read text file line after line and write each line to separate file.
i would like to add a progress bar to the form in order to show the progress( it is a very large file )

any idea how to do that? I have in the Parse class 2 property one for the number of line in the file and the second how much lines already checked.

here is my button2_Click function

   
private void button2_Click(object sender, EventArgs e)
        {
            if (this.textBox1 != null & this.textBox2 != null)
            {
                inst.init(this.textBox1.Text, this.textBox2.Text);
                //this.progressBar1.Show();
                
                inst.ParseTheFile();
                System.Windows.Forms.MessageBox.Show("Parsing finish successfully"); 
            }
        }

Open in new window

0
Comment
Question by:dpatel_team
2 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 36595417
You need to call ParseTheFile() from a different thread, or use a BackgroundWorker() control.

A good technique would be to make the Parser() class raise a custom Progress() event that you subscribe to.  When that event is received you update the Form via delegates/BeginInvoke() or use the ReportProgress() method of the BackgroundWorker().
0
 
LVL 12

Expert Comment

by:Ramkisan Jagtap
ID: 36597235
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C# bracket error 3 35
what is the best portable software where i can test codes written in different languages 1 51
linq, c# 8 22
Why use this lambda? 12 31
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question