Sagar Bora

Sagar Bora

  • NA
  • 1
  • 0

DataGridView column re-ordering through code

Mar 24 2009 4:24 PM
Hi,

I have a datagridview control and a panel control on the form. My 1st target was to drag and drop the column header to the panel so that panel will create the grouping criteria for the datagridview and will sort and group the datagrid accordingly. Till this point I could do everything properly.

Next task is to allow the users to reorder the columns. Here, I am not able to reorder the columns. As I am handling Drag-Drop manually, it is not allowing to reorder the columns (I have set the AllowUserToOrderColumns property to TRUE). If I comment out DoDragDrop call from the MouseDown event of the DataGrid, I can reorder the columns but I can not drag-drop the column headers. So, I believe it's must to use DoDragDrop method and handle the column ordering manually.

Any thoughts as to how to proceed in this case?