DataGridView.DropRow Event
Occurs when users drop a row.
Namespace: DevExpress.XamarinForms.DataGrid
Assembly: DevExpress.XamarinForms.Grid.dll
NuGet Package: DevExpress.XamarinForms.Grid
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 |
---|---|
Allow | Gets or sets whether to allow or prohibit an operation with the row. Inherited from RowAllowEventArgs. |
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 | Gets the grid’s row handle. Inherited from RowEventArgs. |
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 Allow property to false 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.XamarinForms.DataGrid; // ... private void grid_DropRow(object sender, DropRowEventArgs e) { if (e.DropRowHandle == 0 || e.DropRowHandle == 4) { e.Allow = false; DisplayAlert("Alert", "You cannot replace this task: " + ((EmployeeTask)e.DropItem).Name, "OK"); } }