Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to create a Loading Window?
    primarykey
    data
    text
    <p>Ok, in my app there are times when loading the DataGridView can take a minute or two. What I want to do is show a <a href="http://www.pozzware.com/images/edit/wait.gif" rel="nofollow noreferrer">GIF</a> in a form with no border until it reaches the end of the loading function. However, if I do:</p> <pre><code>Views.Loading ldw = new Views.Loading(); ldw.Show(); ... ldw.Close(); </code></pre> <p>...it never actually draws it to the screen and I can't see it. If I do ShowDialog(), it shows the window but never gets past that line of code. I have a feeling it's because it's not a background worker or because the focus gets set back to the parent because of processing...I don't know.</p> <p>My form is a blank form, added a picture box, added a gif to the picture box, and made FormBorderStyle = none. Any and all help is appreciated.</p> <p><b>Update: Current (non-working) Code</b><br></p> <pre><code> private void InitializeBackgroundWorker() { //Defines the DoWork Event Handler for _backgroundWorker. _bgWorkerReports.DoWork += new DoWorkEventHandler(bgWorkerReports_DoWork); //Defines the RunWorkCompleted Event Handler for _backgroundWorker. _bgWorkerReports.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgWorkerReports_RunWorkerCompleted); } private void bgWorkerReports_DoWork(object sender, DoWorkEventArgs e) { ldw.Show(); try { string strFilter = ""; if (!_strSearchFilter.Equals("")) { strFilter += strFilter.Equals("") ? " " + _strSearchFilter : " and " + _strSearchFilter; } if (tvFigure.Nodes.Count &gt; 0) { if (_strFigureFilter == "ALL") { strFilter += " " + Constants.GetColumnName("Figure") + " LIKE '%%' "; } else if (!_strFigureFilter.Equals("") &amp;&amp; !_strFigureFilter.Equals(tvFigure.TopNode.Name)) { if (_strSearchFilter.Equals("") || !cbCurrentFigure.Checked) { strFilter += strFilter.Equals("") ? " " + Constants.GetColumnName("Figure") + "='" + _strFigureFilter + "'" : " and " + Constants.GetColumnName("Figure") + "='" + _strFigureFilter + "'"; } } } if (!_strIndentureFilter.Equals("")) { strFilter += strFilter.Equals("") ? " " + _strIndentureFilter : " and " + _strIndentureFilter; } if (!_strReportFilter.Equals("")) { strFilter += (!strFilter.Equals("") ? " and" : "") + " part_id in (" + _strReportFilter + ")"; } if (strFilter.Length &gt; 0) { BindingSource bSource = new BindingSource(); bSource.DataSource = _dataController.PopulateDataGrid(_nViewMode, strFilter).Tables[0]; //Set DataSource to bindingSource for DataGridView. if (_lstValidationResults.Count &gt; 0) { dgvParts.DataSource = _lstValidationResults; foreach (DataGridViewColumn dc in dgvParts.Columns) { dc.DataPropertyName = "ErrorMessage"; dc.Visible = true; dc.SortMode = DataGridViewColumnSortMode.Programmatic; dc.AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader; } dgvParts.AutoResizeColumns(); return; } else if (!string.IsNullOrEmpty(_strFigureFilter)) { dgvParts.DataSource = bSource; dgvParts.Columns[0].Visible = false; dgvParts.Columns["Description"].Resizable = DataGridViewTriState.False; dgvParts.Columns["Description"].Width = 750; } // Automatically resize the visible rows. foreach (DataGridViewColumn col in dgvParts.Columns) { col.SortMode = DataGridViewColumnSortMode.Automatic; if (col.Name != "Description") { dgvParts.AutoResizeColumn(col.Index); } } dgvParts.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCells; // Hide the ToolTips for all the cells - redisplay if there is a report. dgvParts.ShowCellToolTips = true; // Set the dataGridView control's border. dgvParts.BorderStyle = BorderStyle.Fixed3D; // Get and set the ipb_number to the label. string ipb_number = _dataController.IPBNumber; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void bgWorkerReports_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { ldw.Close(); this.Cursor = Cursors.Default; //Throws error (Cross-thread) FormatCells(); BuildColumnsComboBox(); int nTotalCount = 0; foreach (ListViewItem lvi in listView1.Items) { int nCount = _lstReportRecords.Where(rr =&gt; lvi.Text.Contains(rr.Description)).Count(); nTotalCount += nCount; lvi.Text = (lvi.Text.Contains("(") ? lvi.Text.Substring(0, lvi.Text.IndexOf("(") + 1) : lvi.Text.Trim() + " (") + nCount.ToString() + ")"; } rbAllReports.Text = (rbAllReports.Text.Contains("(") ? rbAllReports.Text.Substring(0, rbAllReports.Text.IndexOf("(") + 1) : rbAllReports.Text + " (") + nTotalCount.ToString() + ")"; int nTaggedCount = _lstReportRecords.Where(rr =&gt; rr.Description.Contains("Tagged")).Count(); rbTaggedRecords.Text = (rbTaggedRecords.Text.Contains("(") ? rbTaggedRecords.Text.Substring(0, rbTaggedRecords.Text.IndexOf("(") + 1) : rbTaggedRecords.Text + " (") + nTaggedCount.ToString() + ")"; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload