title: Why is winform DataGridView control not displaying data after custom columns were added?
body: <p>I have a stored procedure that returns 10 columns [column A, column B, etc].</p>
  
  <p>Based off of that table, a <strong>winform</strong> ListBox is created listing those columns.</p>
  
  <p>The items in the ListBox can be selected, then a "submit" button, which opens up a new Form with a DataGridView on it.</p>
  
  <p>In the new Forms load event, I have placed code that iterates through the column collection and creates the structure of the DataGridView.</p>
  
  <p>The columns I select show up, but the data is not populated into the returned rows.</p>
  
  <pre><code>   StoredProcedures.up_Report_Adapter reportAdapter = new StoredProcedures.up_Report_Adapter();
  
  
          gridCustomData.AutoGenerateColumns = false;
  
          gridCustomData.DataSource = reportAdapter.GetData();
  
          gridCustomData.Columns.Clear();
          gridCustomData.Columns.Add(new DataGridViewColumn() { HeaderText = "REPORT_ID", CellTemplate = new DataGridViewTextBoxCell() });
  
      foreach (var item in customReport.lstBoxSelectFields.SelectedItems)
              {
                  gridCustomData.Columns.Add(item.ToString(), item.ToString());
              }
  
          gridCustomData.Refresh();
  </code></pre>
  
  <p>The right number of rows show up for the data, and if I put a break in at the gridCustomData.Refresh(), I can see that complete data for the columns selected from the ListBox.</p>
  
  <p>So, how do I get the data to actually appear per defined row/column?</p>
  
  <p>I have tried change the order of when the columns are created to before and after the gridCustomData DataSource is updated with the same results.</p>
  
  <p>I also tried creating a BindingSource and using it as the DataSource for the DataGridView, then making the DataSource for the BindingSource the populated table adapter. The data is still not visible.</p>
  
  <p>The goal is to create a "customized query", but really, it just means selecting the columns of what is in the DataSet. I am fetching the entire DataSet returned by the stored procedure (which itself is limited by parameters).</p>
  
  <p>As a side note, if anyone knows of a thorough cookbook for these types of things, I would love to know what its title is. The API data from MSDN is useless as it uses contrived examples.</p>