DataGridView.DropRow Event
Occurs when users drop a row.
Namespace: DevExpress.Maui.DataGrid
Assembly: DevExpress.Maui.DataGrid.dll
NuGet Package: DevExpress.Maui.DataGrid
Declaration
public event EventHandler<DropRowEventArgs> DropRow
Event Data
The DropRow event's data class is DropRowEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Cancel | Gets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs. |
DragItem | Gets a data source item that corresponds to the dragged row. Inherited from DragRowEventArgs. |
DropItem | Gets a data source item that corresponds to the drop target row. |
DropRowHandle | Gets the grid’s dropped row handle. |
RowHandle | Returns the handle of the processed row. Inherited from CancelRowEventArgs. |
Remarks
You can cancel the row drop to specific positions. In this case, a place for the row drop is allocated, but the row returns to its initial position when it is released.
Subscribe to
DropRow
event.<dxg:DataGridView AllowDragDropRows="True" DropRow="grid_DropRow"/>
In the event handler, set the e.Cancel property to
True
to restrict row drop to the specified positions. Use the RowHandle property to obtain the dragged row handle and the DropRowHandle property to get the drop position. To access a data source item (EmployeeTask with the Name property) that corresponds to the drop target row, use the DropItem property.This example shows how to cancel dropping rows in the first and fifth positions:
using DevExpress.Maui.DataGrid; // ... private void grid_DropRow(object sender, DropRowEventArgs e) { if (e.DropRowHandle == 0 || e.DropRowHandle == 4) { e.Cancel = true; DisplayAlert("Alert", "You cannot replace this task: " + ((EmployeeTask)e.DropItem).Name, "OK"); } }