How can I show correctly a progressbar and a label (that show the percentige) for filling multiple datasets?

Hi All,

I need to update a dataGridView that has master-detail part, I use this control for filling the grid and it childs (I use 4 datasets).

Question: How can I add correctly a thread or more that will add to the grid these datasets and show the correct percentage and the UI remain usable?
 
Please provide me some code.

Thanks advanced,
Steve

Here is my code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;


namespace MasterDetail
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }

        MasterControl masterDetail;

        private void frmMain_Load(object sender, EventArgs e)
        {
            //label1.Text = DateTime.Now.ToString();
            clearFields();
            loadData();
            //label2.Text = DateTime.Now.ToString();
        }
        void clearFields()
        {
            panelView.Controls.Clear();
            masterDetail = null;
            Refresh();
            masterDetail = new MasterControl(nwindDataSet);
            panelView.Controls.Add(masterDetail);
        }

        internal delegate void SetDataSourceDelegate();
        private void setDataSource()
        {
            if (this.masterDetail.InvokeRequired)
            {
                this.masterDetail.BeginInvoke(new SetDataSourceDelegate(setDataSource));
            }
            else
            {
                createMasterDetailView();
            }
        }
        void loadData()
        {
            System.Threading.Thread thread =
                       new System.Threading.Thread(new System.Threading.ThreadStart(delegate() { loadDataThread(); }));
            thread.Start();
        }
        void loadDataThread() 
        {
            
            orderReportsTableAdapter.Fill(nwindDataSet.OrderReports);
            invoicesTableAdapter.Fill(nwindDataSet.Invoices);
            employeesTableAdapter.Fill(nwindDataSet.Employees);
            customersTableAdapter.Fill(nwindDataSet.Customers);

            setDataSource();

        }

        void createMasterDetailView() 
        {

            masterDetail.setParentSource(nwindDataSet.Customers.TableName, "CustomerID");
            masterDetail.childView.Add(nwindDataSet.OrderReports.TableName, "Orders");
            masterDetail.childView.Add(nwindDataSet.Invoices.TableName, "Invoices");
            masterDetail.childView.Add(nwindDataSet.Employees.TableName, "Employees");

            typeof(DataGridView).InvokeMember("DoubleBuffered", System.Reflection.BindingFlags.NonPublic |
  System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.SetProperty, null,
  masterDetail, new object[] { true });

            foreach (DataGridView dvg in masterDetail.childView.childGrid)
            {
                typeof(DataGridView).InvokeMember("DoubleBuffered", System.Reflection.BindingFlags.NonPublic |
System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.SetProperty, null,
dvg, new object[] { true });
            }
            masterDetail.childView.childGrid[2].RowTemplate.Height = 100;
        }
        private void btnLoad_Click(object sender, EventArgs e)
        {

        }

        private void btnLoad_Click_1(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}

Open in new window

LVL 13
Molnár IstvánHelpDesk / ProgrammerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Éric MoreauSenior .Net ConsultantCommented:
You can't. No information are returned from the database to the client while loading
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Molnár IstvánHelpDesk / ProgrammerAuthor Commented:
If I do for each ,2x selects: one for counting the total rows and one for loading the entire data?
I'm thinking to count the rows before fill.

The problem is that in every table I have 10000+ rows and the app sometimes it freezes, becomes unresponsive.

Thanks advanced
0
Éric MoreauSenior .Net ConsultantCommented:
but I never saw a case were it was required to show 10000+ rows in datagrids. No users will ever work with that amount of data without filtering/refreshing the data at some point!
0
Éric MoreauSenior .Net ConsultantCommented:
it is the answer even if it is no!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.