title: Bind a DataGridView to a DataSet/DataTable
body: <p>I have two DataTables which I add to a DataSet so that I can achieve a master-view layout. However, I wish to change the appearance of the table, so I need a DataGridView. The problem is that the data below is not binding to the DataGridView and I am getting a null pointer exception when I try to color one of the columns. The column does exist in the data source.</p>
  
  <p>I have tried AugoGenerateColumns = true, BindingSource b = new BindingSource() and this still wouldnt work. </p>
  
  <p>Does anyone know how?        </p>
  
  <pre><code>    DataSet ds = new DataSet();
      ds.Tables.AddRange(new DataTable[] { dtm, dtd });
      ds.Relations.Add("Relationship_name", dcmpk, dcdfk);
  
      DataGridView dgv1 = new DataGridView();
      dgv1.DataSource = ds.Tables[0];
  
      //Null pointer exception
      dgv1.Columns[0].DefaultCellStyle.BackColor = Color.Red;
  </code></pre>
  
  <p>I didn't add my columns to a DataGridView because the DataTable had a PrimaryKey property which was useful for my table layout.</p>