By default, the GridView allows end-users to reorder columns by simply dragging their headers. The same drag-and-drop functionality is available to you in the Visual Studio designer.

You can also specify a column's position using its GridColumn.VisibleIndex property.

Header drag and drop is enabled for all columns by default. To disable it for a particular column, use the OptionsColumn.AllowMove option. Note though that this column's position can change if you move other columns. If you want to completely disable column reorder within the view, use the View's GridOptionsCustomization.AllowColumnMoving option available under GridView.OptionsCustomization.

If you need to respond to column order changes at runtime, handle the View's ColumnView.ColumnPositionChanged event. In the handler, identify the column that was moved using the Sender parameter. Then, display the caption of that column and the Category's column index.
C# |
private void gridView1_ColumnPositionChanged(object sender, EventArgs e) {
GridColumn column = sender as GridColumn;
statusBarText.Caption = string.Format("You've moved the \"{0}\" column. \"Category\" column index is: {1}",
column.GetCaption(), colCategory.VisibleIndex);
}
|
Run the application and move one of the columns. Notice the Category column's position displayed in the status bar.

Now move a column over Category. You'll now see how one column reordering operation can actually affect other columns.