Progress bar in windows application (C#)
-
Wednesday, February 18, 2009 11:48 AMHi,
I'm developing windows application, in that i load the data from excel to datagrid. while loading there are some validations happening. So, in the mean time i want to display the circular progress bar image in the foreground and the validations happenings at the background. will any one let me know what is the simplest way to do this?
thanks in advance ..
All Replies
-
Wednesday, February 18, 2009 12:03 PMSimpliest way would be to use background worker class.
Fresh complete example of background worker class usage:
http://www.dotneat.net/2009/02/10/BackgroundworkerExample.aspx -
Wednesday, February 18, 2009 12:49 PMHi,
Thanks very much for the reply.
My requirement is to use preloader GIF image (Circular image) instead of progress bar.
i just want the image running at the foreground in such a way that user shouldn't be able to do anything in the form (deactivate the form at the background and running the image at the foreground) until it loads the data from Excel to grid.
How to do this ? -
Friday, February 20, 2009 10:49 AM
Hi RM123,
I don't know whether the ProgressCircle control satisfying your requirement, for I don't very clearly understand your "Circular image".
ProgressCircle control links:
ProgressCircle - An Alternative to ProgressBar
WYSIWYG Progress Circle for .Net Framework (C#)
SQL Server 2005 Circular Progress Bar
Please consider using backgroundWorker Giedrius has advised and ProgressCircle control to do your job.
Code Snippet:private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { this.Enabled = false; //set your form to unuse when in validatin DateTime start = DateTime.Now; e.Result = ""; for (int i = 0; i < 100; i++) { System.Threading.Thread.Sleep(50); //do your task, loading data backgroundWorker1.ReportProgress(i, DateTime.Now); //notify progress to main thread. } } private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e) { //update your progressCircle1 according to e.ProgressPercentage } private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { //check your validatin result and do your following task this.Enabled = true; } private void btoStart_Click(object sender, EventArgs e) { backgroundWorker1.RunWorkerAsync(); } Please have a try.
Best regards,
Guo
- Marked As Answer by Guo Surfer Tuesday, February 24, 2009 3:10 AM
-
Saturday, December 12, 2009 6:09 PMi have the same scenario...did you get it to work?

