Bound datagridvewview column ordering confusion
-
Hello, So, I've got a DataGridView that is bound to some data in a DataTable. I only show a subset of the columns and additionally have two non-bound columns in the DataGridView. I've attempted to set the column ordering via the DisplayIndex property to no avail. If I attempt to set the DisplayIndex for each in ascending order such as: column0.DisplayIndex = 0; column1.DisplayIndex = 1; . . . column9.DisplayIndex = 9; the columns don't order correctly. They end up showing up as follows (numbers are the order that I specified them in): 0, 1, 2, 6, 8, 4, 7, 3, 9, 5 The two non-bound columns are 6 and 8 and are DataGridViewImagaColumns. The others are text columns. Has anyone else had such a problem and solved it? I saw some similar questions asked in my google searching but didn't see a solution to this. I wonder if it is a bug or perhaps I'm just missing something here. Thanks for you help, Matt
TODO: Think up something witty to put here.
-
Hello, So, I've got a DataGridView that is bound to some data in a DataTable. I only show a subset of the columns and additionally have two non-bound columns in the DataGridView. I've attempted to set the column ordering via the DisplayIndex property to no avail. If I attempt to set the DisplayIndex for each in ascending order such as: column0.DisplayIndex = 0; column1.DisplayIndex = 1; . . . column9.DisplayIndex = 9; the columns don't order correctly. They end up showing up as follows (numbers are the order that I specified them in): 0, 1, 2, 6, 8, 4, 7, 3, 9, 5 The two non-bound columns are 6 and 8 and are DataGridViewImagaColumns. The others are text columns. Has anyone else had such a problem and solved it? I saw some similar questions asked in my google searching but didn't see a solution to this. I wonder if it is a bug or perhaps I'm just missing something here. Thanks for you help, Matt
TODO: Think up something witty to put here.
Hey, I don't know if there is a reason your changing the order via the DisplayIndex, or what your using to write your code, but if you right click on the datagridview and go edit columns, then you can change the order by moving them up and down in the list(In Visual Studio .NET 2005). Hope that helps, if not disregard.