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.开发者_如何学编程
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;
精彩评论