private void MainForm_Shown(object sender, EventArgs e) { //speedUP on datasource updating DGVPrices.Hide(); DGVPrices.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None; MainPricesDT.BeginLoadData(); if (File.Exists(@"Resources/elements.xml")) { DataSet ds = new DataSet(); ds.ReadXml(@"Resources/elements.xml"); foreach (DataTable table in ds.Tables) { if (table.TableName == "Materials") { MainPricesDT = CreatePriceTable(); MainPricesDT = table; } } } else { MainPricesDT = ReadTxt(); } MainPricesDT.EndLoadData(); ShowPriceDGV(); LoadBPRXML(); }
private void ShowPriceDGV() { DGVPrices.DataSource = MainPricesDT; DGVPrices.Columns["ID"].DefaultCellStyle = new DataGridViewCellStyle { Format = "N0" }; DGVPrices.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; DGVPrices.Show(); }
private void UpdatePricesThrd() { int totalRows = MainPricesDT.Rows.Count; PriceKeys.Clear(); for (int row = 0; row < totalRows; row++) { if (MainPricesDT.Rows[row]["ID"] != null) { PriceKeys.Add(MainPricesDT.Rows[row]["ID"].ToString(), row); } } Invoke((MethodInvoker) delegate { ProgressBarPrice.Maximum = totalRows - 1; ProgressBarPrice.Minimum = 0; ProgressBarPrice.Value = 0; DGVPrices.DataSource = null; DGVPrices.Hide(); DGVPrices.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None; }); string matIDs = ""; for (int row = 0; row < totalRows; row++) { if (MainPricesDT.Rows[row]["ID"] != null) { matIDs += MainPricesDT.Rows[row]["ID"].ToString() + (((row % PageSize == 0) || (row == totalRows - 1)) ? "" : ","); if (((row % PageSize == 0) || (row == totalRows - 1)) && (matIDs != "")) { string IDs = matIDs; matIDs = ""; Thread nextQ = new Thread(new ParameterizedThreadStart(UpdateDt)); ThreadStrInt StrInt = new ThreadStrInt(); StrInt._str = IDs; StrInt._int = row; nextQ.Start(StrInt); } } } }