How to add a column to the first position

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.
 
S

Scott M.

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.
 
M

Morten Wennevik

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);
 
S

Scott M.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top