Unexpected result in deleting DataGridView Columns
<pre><code>        DataTable dt = new DataTable();
        dt.Columns.Add("col1");
        dt.Columns.Add("col2");
        dt.Columns.Add("col3");
        dt.Columns.Add("col4");
        dt.Columns.Add("col5");
        dataGridView1.DataSource = dt;
        dataGridView1.Columns.RemoveAt(3);
        dataGridView1.Columns.RemoveAt(2);
        dataGridView1.Columns.RemoveAt(0);
</code></pre>

<p>In this program, I created a DataTable with 5 columns. This will be the DataSource of the DataGridView. Some columns in the DataTable doesn't need to be seen by the user, but will be used by the program later on.</p>

<p>After the last line, the columns are arranged as : col2, col5, col1, col3, col4. Why does it appear like this? Shouldn't it be removed from the DataGridView? What should I do to make it appear as "col2, col5"?</p>

<p>EDIT: I want to <em>remove</em> some Columns from the DataGridView, yet still be available in the DataTable. Also, it works inside an event (like Button_Click)</p>

<p>EDIT: I <strong>still</strong> haven't figured out why this is happening. I have no choice but to create another thread (BackgroundWorker) to do this...</p>

<pre><code>    private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
    {
        DataTable dt = new DataTable();
        int i;
        dataGridView1.Invoke((MethodInvoker)delegate
        {
            dt.Columns.Add("col1");
            dt.Columns.Add("col2");
            dt.Columns.Add("col3");
            dt.Columns.Add("col4");
            dt.Columns.Add("col5");
            dataGridView1.DataSource = dt;
            dataGridView1.Columns.RemoveAt(3);
            dataGridView1.Columns.RemoveAt(2);
            dataGridView1.Columns.RemoveAt(0);
        });
    }
</code></pre>

<p>As far as I can tell, Haris Hasan was right; that the Form containing the DataGridView should appear at least once. But I'm still confused why...</p>
