Skip to main content
A newer version of this page is available. .

GridView.DragObjectOver Event

Enables you to control whether the dragged column header or band header can be dropped at the current position.

Namespace: DevExpress.XtraGrid.Views.Grid

Assembly: DevExpress.XtraGrid.v18.2.dll

Declaration

[DXCategory("DragDrop")]
public event DragObjectOverEventHandler DragObjectOver

Event Data

The DragObjectOver event's data class is DragObjectOverEventArgs. The following properties provide information specific to this event:

Property Description
DragObject Gets the column or band whose header is being dragged.
DropInfo Gets an object containing information about the dragged header’s current position.

Remarks

The DragObjectOver event fires repeatedly when dragging a column or band header. This event lets you prevent dropping at the current position.

Use the event’s DragObjectOverEventArgs.DragObject and DragObjectOverEventArgs.DropInfo parameters to identify the element being dragged and to obtain its current position. To prevent dropping, set the Valid property of the DragObjectOverEventArgs.DropInfo object to false. This changes the mouse cursor to the MouseCursorNo image and the View will ignore a subsequent drop of the dragged object.

Note that the GridView.DragObjectDrop event occurs regardless of the operation’s result. Its DragObjectDropEventArgs.Canceled parameter will be set to false if the drag and drop operation was canceled.

For general information on handling column and band header dragging, see the GridView.DragObjectStart topic.

Example

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");
    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the DragObjectOver event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also