473,394 Members | 1,889 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Problem related to progressbar control

15
What I am trying to figure out is how to display a progress bar when im performing a large task. This task will consist of reading records from a database, writing them to a text file, manipulating the data to write to a database and then present them on the screen. There can be several thousand records that I have to manipulate. I am having trouble getting a progressbar to accuratly display the progress. My problem seems to be that since i cant determine exactly how many records and how much time it will take that I cant accuratly update the progressbar. Any help is appreciated. Thanks
May 16 '09 #1
2 1912
tlhintoq
3,525 Expert 2GB
My problem seems to be that since i cant determine exactly how many records
If you don't know how many records, then how are you able to go through them all? You either know how many at *some* point or you don't. If you don't know how many you are working with then not only could you not accurately produce a progress bar, but you wouldn't be able to ensure you are handling them all.
May 16 '09 #2
Frinavale
9,735 Expert Mod 8TB
When you read from the Database you will know the number of records that you are manipulating.

Set the progress bar's Maximum property to this number.....

VB code example:
Expand|Select|Wrap|Line Numbers
  1. Dim totalNumberOfRecords As Integer 'This number is set when you retrieve the records from the database
  2.  
  3. Private Sub CopyWithProgress(ByVal ParamArray filenames As String())
  4.     ' Display the ProgressBar control.
  5.     pBar1.Visible = True
  6.     ' Set Minimum to 1 to represent the first file being copied.
  7.     pBar1.Minimum = 1
  8.     ' Set Maximum to the total number of records
  9.     pBar1.Maximum = totalNumberOfRecords
  10.     ' Set the initial value of the ProgressBar.
  11.     pBar1.Value = 1
  12.     ' Set the Step property to a value of 1 to represent each file being copied.
  13.     pBar1.Step = 1
  14.  
  15.     ' Loop through all files to copy.
  16.     Dim x As Integer
  17.     for x = 1 To totalNumberOfRecords - 1
  18.           'Do Stuff....Then
  19.           'Perform the increment on the ProgressBar.
  20.            pBar1.PerformStep()
  21.     Next x
  22. End Sub

C# code:
Expand|Select|Wrap|Line Numbers
  1. Integer  totalNumberOfRecords // This number is set when you retrieve the records from the database
  2. private void CopyWithProgress(string[] filenames)
  3. {
  4.   // Display the ProgressBar control.
  5.   pBar1.Visible = true;
  6.   // Set Minimum to 1 to represent the first file being copied.
  7.   pBar1.Minimum = 1;
  8.   // Set Maximum to the total number records.
  9.   pBar1.Maximum =totalNumberOfRecords ;
  10.   // Set the initial value of the ProgressBar.
  11.   pBar1.Value = 1;
  12.   // Set the Step property to a value of 1 to represent each file being copied.
  13.   pBar1.Step = 1;
  14.  
  15.    // Loop through all files to copy.
  16.    for (int x = 1; x <= totalNumberOfRecords; x++)
  17.    {  //Do Stuff...Then:
  18.       // Perform the increment on the ProgressBar.
  19.      pBar1.PerformStep();
  20.  
  21.    }
  22. }
May 20 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Maka Sili | last post by:
Using ProgressBar.Enabled = false does not dim the progress bar. There must be a way. I hope somebody could guide me. Thanks.
1
by: Geir Baardsen | last post by:
Hi! Is there any clear examples on how to use the Progressbar (6.0) in ms access 2000 anywhere? Me.Name
2
by: Thomas Kehl | last post by:
Hi! Does anyone have a tipp for me where can I found (or how can I programm) a "progressbar" which has a gradient and the color go from the left side to right and back ... I should have a...
8
by: needin4mation | last post by:
Please consider: foreach (ListViewItem item in listViewFiles.Items) { // Display the ProgressBar control. pBar1.Visible = true; // Set Minimum to 1 to represent the first file being copied....
1
by: Mehr H | last post by:
I've been trying to figure out how i can embed a Windows.Forms.ProgressBar in my webform (aspx) file. I have tried putting a Windows.Forms.ProgressBar as public on a regular winform designer form...
1
by: Glenn Owens | last post by:
I have a Web DataGrid into which I've added a templatecolumn. Into the templatecolumn I've placed a progressbar custom control (which provides its rendering by overriding the Render method of the...
13
by: MrKrich | last post by:
I use ProgressBar control and one Label to display the status of the process. Both of them are placed in panel object. When the process finish doing one task and before start the other task, it...
3
by: Mitchell Vincent | last post by:
In other programming languages I've been able to easily change the style of a progress bar between smooth and blocked. I find that is either really hidden or impossible in .NET. Am I missing...
1
by: daniel_xi | last post by:
Hi all, I am running a VS 2003 .NET project on my client machine (Win 2000 SP4, ..NET framework 1.1), running an ASP.NET application on a remote web server (Win 2000 Server, IIS 6.0, .NET...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.