The example shows how to prevent moving the “ContactName” column to the Customization Form.
To control drag-and-drop of grid columns, we handle the GridView.DragObjectOver event. The DragObjectOverEventArgs.DropInfo event’s parameter contains information on the current position where drag-and-drop will occur if the end-user drops the drag object. The Index property of the DragObjectOverEventArgs.DropInfo would be -1 when dragging over the Customization Form.
using DevExpress.XtraGrid.Views.Base;
private void bandedGridView1_DragObjectOver(object sender, DragObjectOverEventArgs e) {
GridColumn column = e.DragObject as GridColumn;
if (column != null) {
e.DropInfo.Valid = !(e.DropInfo.Index == -1 && column.FieldName == "ContactName");
}
}
Imports DevExpress.XtraGrid.Views.Base
Private Sub BandedGridView1_DragObjectOver(ByVal sender As Object, _
ByVal e As DragObjectOverEventArgs) Handles BandedGridView1.DragObjectOver
If TypeOf e.DragObject Is GridColumn Then
Dim column As GridColumn = CType(e.DragObject, GridColumn)
e.DropInfo.Valid = Not (e.DropInfo.Index = -1 And column.FieldName = "ContactName")
End If
End Sub