Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for (int i = 0; i < dgItemMaster.Rows.Count; i++)
- {
- if (dgItemMaster.Rows[i].DataBoundItem.GetType().Name == "Package")
- {
- dgItemMaster.Rows[i].DefaultCellStyle.BackColor = Color.PowderBlue;
- }
- }
- void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
- {
- dgItemMaster.DataSource = products;
- dgItemMaster.BeginInvoke((Action)(() =>
- {
- for (int i = 0; i < dgItemMaster.Rows.Count; i++)
- {
- if (dgItemMaster.Rows[i].DataBoundItem.GetType().Name == "Package")
- {
- dgItemMaster.Rows[i].DefaultCellStyle.BackColor = Color.PowderBlue;
- }
- else if (dgItemMaster.Rows[i].DataBoundItem.GetType().Name == "PackageKit")
- {
- dgItemMaster.Rows[i].DefaultCellStyle.BackColor = Color.Pink;
- }
- }
- }));
- }
- int startIndex = 0;
- Action action = null;
- action = () =>
- { // only processes a batch of 50 rows, then calls BeginInvoke
- // to schedule the next batch
- int endIndex = startIndex + 50;
- if (endIndex > dgItemMaster.Rows.Count) endIndex = dgItemMaster.Rows.Count;
- if (startIndex > endIndex)
- {
- for (int i = startIndex; i < endIndex; i++)
- {
- // process row i
- }
- startIndex = endIndex;
- this.BeginInvoke(action); // next iteration
- }
- };
- // kick it off
- this.BeginInvoke(action);
Add Comment
Please, Sign In to add comment