title: c# datagridview datasource
body: <p>I am creating a Datagridview programmatically in a dll file.
  It's datasource is a Datatable, and my code is as such:</p>
  
  <pre><code>DataGridView dgv = new DataGridView();
  DataSet ds = new DataSet();
  ds.ReadXml(rdr);
  DataTable dt = ds.Tables[0];
  
  dgv.DataSource = dt;
  </code></pre>
  
  <p>Why then when I check how many columns and rows the datagrid has, it shows as nothing.  Although, when I do the same check on the Datatable it shows that there is data.
  Does the gridview need to be actually on a form for it to be populated?</p>
  
  <p>Thanks.</p>