Will Tonkin
Will Tonkin

Reputation: 1

Datagridview Column Header Order changes between XP and Win7

I had a VS2008 VB.NET project that uses a datagridview that was created on an XP machine. Now I loaded the project, still in VS2008, but when I run the code everything works except now the datagridview columns are reorder to be alphabetical by column name. I have searched extensively online, but could not find any clues. Does anyone know what causes this, and more importly how do I fix it.

Thanks in advance for any assistance.

Upvotes: 0

Views: 149

Answers (1)

mugume david
mugume david

Reputation: 635

You need to specify the display column index as in the code below. Had a somewhat similar problem. The order specified always sticks if you use this approach.

dataGridView1.Columns["idColumn"].DisplayIndex = 0;
dataGridView1.Columns["namesCoulmn"].DisplayIndex = 1;

Upvotes: 1

Related Questions