Molnár István
asked on
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:
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();
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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!
it is the answer even if it is no!
ASKER
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