How to add a column to the first position

  • Thread starter Thread starter ad
  • Start date Start date
A

ad

I use the code below to add a columns to the columns of a table.
Table1.Columns.Add("NewField", typeof(string));
But it always add the clolumn to the last position.
How can I add a column to the first position.
 
The only way to do it is to make it first. But, why do you need to adjust
the order of the columns anyway? You can extract the data in any order you
need to.
 
The only way to do it is to make it first. But, why do you need to
adjust
the order of the columns anyway? You can extract the data in any order
you
need to.

That is not correct. You can reorder columns after they have been created
by using SetOrdinal


Table1.Columns.Add("NewField", typeof(string)).SetOrdinal(0);
 
This is only available in the 2.0 Framework. I (correctly or incorrectly)
assumed the question was a 1.1 question. In 1.1, there is no way to re-order
the columns after they have been added.
 
Back
Top