title: C# DataGridView Column Order
body: <p>In my application, I have a <code>DataGridView</code> whose data source varies depending on the button you click.</p>
  <p>For example, clicking 'Total Downloads' will be:</p>
  <pre><code>dataGridView1.DataSource = totalDownloads();
  </code></pre>
  <p>Or the downloads per player</p>
  <pre><code>dataGridView1.DataSource = playerDownloads();
  </code></pre>
  <p>Each method obtains data via SQL query and returns a <code>dataTable</code> of this information.</p>
  <p>However, with my following code:</p>
  <pre><code>dataGridView1.DataSource=getStats();
  public DataTable getStats()
     {
          DataTable table1 = new DataTable(&quot;Totals&quot;);
          table1.Columns.Add(&quot;Park Name&quot;);
          table1.Columns.Add(&quot;Author&quot;);
          table1.Columns.Add(&quot;Total Downloads&quot;);
          table1.Columns[2].DataType = typeof(int);
          table1.Columns.Add(&quot;Rating (Max 5)&quot;);           
          table1.Columns[3].DataType = typeof(float);
          table1.Rows.Add(name,author,download, rating);
          }
          return table1;
      }
  </code></pre>
  <p>I expected to see the columns in the order: &quot;Park Name&quot; &quot;Author&quot; &quot;Total Downloads&quot; &quot;Rating&quot;
  However, they come in &quot;Downloads&quot;, &quot;Park Name&quot;, &quot;Author&quot;, &quot;Rating&quot;</p>
  <p>I've read that adding <code>dataGridView1.AutoGenerateColumns = false;</code>
  will fix this...however, this makes no difference to the order at all...</p>