title: DataGridView not autosizing columns until show
body: <p>I have a custom control that essential shows a DataGridView popup when a button is clicked. I want to resize the popup to the size of the DataGridView columns. I have set the AutoSize modes when the DataGridView  is created.</p>
  
  <pre><code>dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
  dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
  </code></pre>
  
  <p>I also call the following method right before calculating the total column size.</p>
  
  <pre><code>public void AutoResize()
  {
      dataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
      dataGridView1.AutoResizeRows(DataGridViewAutoSizeRowsMode.AllCells);
      dataGridView1.Refresh();
  }
  </code></pre>
  
  <p>The first time the popup is shown it has not been resized properly. This, as far as I can tell, is because the AutoSize of the columns doesn't take place until the dataGridView control is displayed once.</p>
  
  <p>This is the order of execution.</p>
  
  <p>CreateCustomControl -> CreateDataGridView (with data) -> AddToCustomControl -> CallAutoResize -> ShowCustomControl (with DataGridView)</p>
  
  <p>A simple solution is for me to resize the control after it is displayed. I still would like to know why the AutoResize doesn't take place until the control is shown?</p>
  
  <p>Thank you in advanced for your help.</p>