Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Windows Application VB.NET , +
Hi,
 
In My windows application I am loading huge data in Datagridview ( using data source dgv.datasource=ds.Table(0) ),it is taking more time load so user cant understand it is loading or application hanged so i want to display the loading status in progressbar or something which user can understand that data is loading....
 
if possible please give me sample code....

Please Help me....
Posted 26-Nov-12 20:07pm
Edited 27-Nov-12 0:54am
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Try this as an example.
 
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
 
    'Do NOT (ever) refer to form controls from this method
    'Keep it self contained

    'Add your background code

    'As you pass through each loop in your long runtime method do something like this
    BackgroundWorker1.ReportProgress(CInt((countsofar / totalofthingstodo) * 100))
 
End Sub
 
Private Sub BackgroundWorker1_ProgressChanged(ByVal sender As System.Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged
    'Only ever refer to form controls from this method
    ProgressBar1.Value = e.ProgressPercentage
End Sub
 
Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As System.Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
    ProgressBar1.Value = ProgressBar1.Minimum
End Sub
Where it says ''Add your background code', use that to fill a DataSet (created programatically, not a form control) and once the background worker has finished you can attach the DataSet to the DataGridView.
 
Mike
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Do the DataGridView Loading via a BackgroundWorker, you'll need to populate an object you create in the BackgroundWorker thread rather than the DGV directly (since you shouldn't interact with the UI thread from the BackgroundWorker thread) and then copy the data to the DGV when it finishes. Use something like this[^] as your progress bar and the ReportProgress functionality of the BackgroundWorker to update it to show progress and a message.
 
M
  Permalink  
Comments
bayramchik at 15-Mar-13 0:17am
   
Could you please provide sample code. Thanks in advance
Mike-MadBadger at 15-Mar-13 3:25am
   
See the following answer.

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



Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 15 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100