Click here to Skip to main content
15,912,072 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to assign a particular task in Progress Bar?
For Example:
I am retrieving large amount of data from Database and filling it in DataGrid View.Now I Want to show the progess of this process in the progressbar.How can it be done?
Posted

It's impossible. You don't 'assign a task' to a progress bar. You write code that tracks the progress of a task, and positions the progress bar accordingly. Turns out that programming sometimes means writing code, not just using a designer. Your database operation does not give you any feedback, so you cannot show a progress bar to show how long it takes to perform a single SQL call. If you're making many calls, you can divide your progress bar into the number of calls being made, and move it between calls.
 
Share this answer
 
Comments
Chris Trelawny-Ross 27-Aug-10 19:53pm    
"Turns out that programming sometimes means writing code, not just using a designer." Who'd have thought?
If you're loading so much data into a grid that you need a progress bar to tell the user its still loading, I suspect that you have a lurking usability problem - specifically that you are making far too much data available to the user and it will be impossible for the user to make meaningful use out of it (the needle in a haystack comes to mind).

If your customer simply insists that they need all 100,000 rows (or whatever) available in the grid at all times, I recommend that you look into techniques for paging data into the grid. Some 3rd party grids have built-in infrastructure to support this (so the grid only loads the rows in needs to be able to show a full page of data, and you only ever load data that the user actually looks at).

if you're not using a grid that helps, you'll have to write your own paging. As Christian says, with each page loaded you can increment your progress bar; a side benefit of doing your own paging (if you do it right) is that the user can view and start working with the data from the first page(s) loaded while the remainder of the data is still loading. But, for that, you'll have to have fun with threading and thread-safe collections.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900