I have a sorted list containing column headers, how do I change the order of the datagridview so that it is in the same order as the sorted list?
I tried the code below, but this does not always work, some columns are not sorted correctly. Thanks for any help with this.
sortedColumnNames.Sort(); foreach (DataGridViewColumn col in dataGridView1.Columns) { col.DisplayIndex = sortedColumnNames.IndexOf(col.HeaderText); }
sortedColumnNames: Athens Crete Corfu Kefalonia Mykonos Rhodes Santorini Skiathos Zante
Jason p
source share