Skip to content

Infragistics Community Forum / Desktop / Ultimate UI for Windows Forms / Progress or wait message while data is loading?

Progress or wait message while data is loading?

New Discussion
Jason
Jason asked on Jan 10, 2008 5:44 PM

Is there some way to display a progress or wait message while data is loading into a grid?  I saw that there is a UseWaitCursor, but that did not seem to work as it always used the wait cursor even if data was not loading.

Thanks.

Sign In to post a reply

Replies

  • 0
    Jason McIntosh
    Jason McIntosh answered on Jan 8, 2008 1:27 AM

    You might need to put the loading of data into the grid into a background worker process. Then you can use the enquire Progress Bar tool and enquire of the background working to update the progress.

    Here is one example of this occuring, but insteadof using the Progress Bar tool, they have simply output a string of the percent complete.

    Hope this helps.

    Jason

    • 0
      Cá chu?i
      Cá chu?i answered on Jan 8, 2008 8:04 AM

      Hi,

       BackgroundWorker only raise event ProgressChanged when you call method ReportProgress(). Could you show me how to calculate percent complete of loading data into grid and grid render to display.

      My application have data about 20.000 – 50.000, so I need this very much.

      Thanks! 

      • 0
        Jason McIntosh
        Jason McIntosh answered on Jan 9, 2008 11:45 PM

        Now you have got me. I have seen it done, but i dont really know quite how they did it.

        Should it not be possible to run the fill for your dataset in the Background worker, and then use a loop to run the ReportProgress method, also setting the progress on your ProgressBar?

        I dont know…I am just playing with ideas here.

        Anyone else got any ideas?

      • 0
        Andre Kraemer
        Andre Kraemer answered on Jan 9, 2008 11:57 PM

        Hi,

        there’s a knowledgebase entry on that topic.

         

      • 0
        Ralf Friedrich
        Ralf Friedrich answered on Jan 10, 2008 7:30 AM

        Hi,

        I am using a progress animation to visualize the loading progress. It looks like the progress control the SQL server 2005 is using. When the loading was started, the control will be shown (RotatingProgress.Show() for example). And when the BackgroundWorker raise the Completed event, the control will be hidden.

        If you using a DataTable as DataSource for the grid I have some code using the DataReader to load rows just in time into the grid. This code will also using a BackgroundWorker. I have the code not here at work, but I can put it here today.

        Kind regards,

        Ralf

      • 0
        Ralf Friedrich
        Ralf Friedrich answered on Jan 10, 2008 5:44 PM

        Hi,now I’m at home and I can show you the code to load data into a grid just in time using a DataSet.At first the form. It will be use a ultragrid and a button to start the data load. Add a BackgroundWorker to the code of the form and add methods to handle the events of the BackgroundWorker. Add a variable for a DataSet.public partial class Form1 : Form{private DataSet _ds;private BackgroundWorker _backgroundWorkerRowLike; In the button_Click event  Add the following code:_ds = new DataSchemas.NewDataSet(); // a DataSet requires a schemadataGridView3.DataSource = _ds.Tables[0]; // use the ultragrid insteadif (_backgroundWorkerRowLike == null){_backgroundWorkerRowLike = new BackgroundWorker();_backgroundWorkerRowLike.WorkerReportsProgress = true;_backgroundWorkerRowLike.WorkerSupportsCancellation = true;_backgroundWorkerRowLike.DoWork += newDoWorkEventHandler(_backgroundWorkerRowLike_DoWork);_backgroundWorkerRowLike.ProgressChanged += new ProgressChangedEventHandler(_backgroundWorkerRowLike_ProgressChanged);_backgroundWorkerRowLike.RunWorkerCompleted += new RunWorkerCompletedEventHandler(_backgroundWorkerRowLike_RunWorkerCompleted);}if (!_backgroundWorkerRowLike.IsBusy)_backgroundWorkerRowLike.RunWorkerAsync(new SqlCommand(“SELECT * FROM Orders”)); The working method of the BackgroundWorker looks like this:private void _backgroundWorkerRowLike_DoWork(object sender, DoWorkEventArgs e){BackgroundWorker bw = sender as BackgroundWorker;SqlConnection _connection = new SqlConnection(“add your connectionsttring here”);SqlDataReader reader;SqlCommand command = (SqlCommand)e.Argument;try{if (_connection.State != ConnectionState.Open){_connection.Open();command.Connection = _connection;reader = command.ExecuteReader();while (reader.Read()){object[ values = new object[reader.FieldCount – 1];reader.GetValues(values); // store the row values into an array of objectbw.ReportProgress(1, values); // Send the row values to the UI threadThread.CurrentThread.Join(10); // Set the thread to sleep 20 ms to let the grid time to update}}}catch (Exception ex){// Add your exception handling here…}finally{if (_connection.State == ConnectionState.Open)_connection.Close();}}In the PreportProgress event we can add the row values to the DataSet.private void _backgroundWorkerRowLike_ProgressChanged(object sender, ProgressChangedEventArgs e){If (e.UserState != null){_ds.Tables[0].LoadDataRow((object[)e.UserState, true);}} When you running the sample each returned row of the DataReader will be send as an array of object to the UI thread and there it can be added to the DataSet. The ultragrid will be add and show each added row automatically. The user of the application will see that the data load is in progress.In the button_Click event you can additionally start showing a “Please wait” control and close/hide ist in the RunWorkerCompleted event. Please note: the code samples are copied out of more complexe code. If it will not be running, please give me a little info. I will create a complete sample app then.Kind regards,Ralf

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Jason
Favorites
0
Replies
6
Created On
Jan 10, 2008
Last Post
18 years, 1 month ago

Suggested Discussions

Tags

Created by

Created on

Jan 10, 2008 5:44 PM

Last activity on

Feb 16, 2026 1:53 PM