Class RowDragDropController
Represents a base class that provides the base implementation for Row drag-and-drop operations in SFDataGrid.
Inheritance
Implements
Inherited Members
Namespace: Syncfusion.WinForms.DataGrid.Interactivity
Assembly: Syncfusion.SfDataGrid.WinForms.dll
Syntax
public class RowDragDropController : IDisposable
Constructors
RowDragDropController(TableControl)
Initializes a new instance of the RowDragDropController class.
Declaration
public RowDragDropController(TableControl tablecontrol)
Parameters
| Type | Name | Description |
|---|---|---|
| TableControl | tablecontrol |
Methods
Dispose()
Releases resources used by this instance and detaches event handlers.
Declaration
public void Dispose()
DrawDragPreviewRow(TableControl, List<Int32>)
Generates a bitmap representation of a grid row for use as a drag preview during row operations.
Declaration
protected virtual Bitmap DrawDragPreviewRow(TableControl tableControl, List<int> rowIndexes)
Parameters
| Type | Name | Description |
|---|---|---|
| TableControl | tableControl | The TableControl instance that provides the grid structure and row data. |
| System.Collections.Generic.List<System.Int32> | rowIndexes | A collection of visual row indexes to be included in the generated bitmap. |
Returns
| Type | Description |
|---|---|
| System.Drawing.Bitmap | A System.Drawing.Bitmap containing the rendered row preview, or |
Remarks
Override this method to customize the drag row preview
GetDropPosition(DragEventArgs, TableControl, SfDataGrid, RowColumnIndex, IList<Object>, out Object)
Determines the drop position (Above or Below) for a drag-and-drop operation and retrieves the target record data.
Declaration
protected virtual DropPosition GetDropPosition(DragEventArgs e, TableControl targetTable, SfDataGrid sourceGrid, RowColumnIndex rowColumnIndex, IList<object> draggingRecords, out object targetRecordData)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Forms.DragEventArgs | e | The System.Windows.Forms.DragEventArgs containing drag data and mouse position. |
| TableControl | targetTable | The target TableControl where the drop is evaluated. |
| SfDataGrid | sourceGrid | |
| RowColumnIndex | rowColumnIndex | The RowColumnIndex representing the hovered row and column. |
| System.Collections.Generic.IList<System.Object> | draggingRecords | The list of records being dragged. |
| System.Object | targetRecordData | Outputs the target record data at the drop location. |
Returns
| Type | Description |
|---|---|
| DropPosition | A DropPosition value indicating Above, Below, or None if the drop is invalid. |
Remarks
Override to implement custom drop position rules or validation logic.
HideDropIndicator()
Hides the visual drop indicator during a drag-and-drop operation.
Declaration
protected virtual void HideDropIndicator()
Remarks
Override this method to customize how the drop indicator is cleared or hidden.
ProcessOnDragDrop(Object, DragEventArgs)
Handles the drop operation during row drag-and-drop by validating the target, inserting records, raising events, and cleaning up visuals.
Declaration
protected virtual void ProcessOnDragDrop(object sender, DragEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | sender | The grid control handling the drop. |
| System.Windows.Forms.DragEventArgs | e | The System.Windows.Forms.DragEventArgs containing drop data and mouse position. |
Remarks
Override to implement custom drop logic or modify cleanup behavior.
Call base.ProcessOnDragDrop(sender, e) to retain default functionality.
ProcessOnDragOver(Object, DragEventArgs)
Processes the drag-over event for a row drag-and-drop operation. Validates the target location, determines the drag effect, updates the cursor, and displays the drop indicator.
Declaration
protected virtual void ProcessOnDragOver(object sender, DragEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | sender | The source of the event, typically the control initiating the drag operation. |
| System.Windows.Forms.DragEventArgs | e | Provides data for the drag-over event, including cursor position and drag data. |
Remarks
Override this method to implement custom drag-over logic or modify default behavior.
ProcessOnDragStart(TableControl, RowColumnIndex, MouseEventArgs)
Initiates a row drag-and-drop operation. Validates the drag source, raises the DragStart event.
Declaration
protected virtual void ProcessOnDragStart(TableControl tableControl, RowColumnIndex dragSourceRowIndex, MouseEventArgs args)
Parameters
| Type | Name | Description |
|---|---|---|
| TableControl | tableControl | The TableControl instance associated with the grid where the drag operation starts. |
| RowColumnIndex | dragSourceRowIndex | A RowColumnIndex representing the visual row index where the drag was initiated. |
| System.Windows.Forms.MouseEventArgs | args | The System.Windows.Forms.MouseEventArgs containing mouse input details for the drag initiation. |
Remarks
Override this method to customize drag initiation logic, such as validating rows,
canceling drag for specific conditions, or adding custom behaviors before starting the drag.
When overriding this method, ensure to call base.ProcessOnDragStart(tableControl, dragSourceRowIndex, args)
to retain the default drag-and-drop behavior, including event invocation and drag preview initialization.
ShowDropIndicator(TableControl, Int32, DropPosition)
Displays the drop indicator line at the specified row position during a drag-over operation.
Declaration
protected virtual void ShowDropIndicator(TableControl targetTableControl, int rowIndex, DropPosition position)
Parameters
| Type | Name | Description |
|---|---|---|
| TableControl | targetTableControl | The target TableControl where the indicator should appear. |
| System.Int32 | rowIndex | The visual row index used to position the indicator. |
| DropPosition | position | Specifies whether the indicator should appear above or below the row. |
Remarks
Override this method to customize the indicator's appearance or behavior.
Events
DragLeave
Raised when the dragged row leaves a previously hovered drop target.
Declaration
public event EventHandler<GridRowDragLeaveEventArgs> DragLeave
Event Type
| Type |
|---|
| System.EventHandler<GridRowDragLeaveEventArgs> |
DragOver
Raised continuously while a dragged row is hovering over a potential drop target.
Declaration
public event EventHandler<GridRowDragOverEventArgs> DragOver
Event Type
| Type |
|---|
| System.EventHandler<GridRowDragOverEventArgs> |
DragStart
Raised when a row drag operation is initiated. Provides details about the source row and drag context.
Declaration
public event EventHandler<GridRowDragStartEventArgs> DragStart
Event Type
| Type |
|---|
| System.EventHandler<GridRowDragStartEventArgs> |
Drop
Raised when a drop action is requested (before committing). Enables validation or cancellation of the drop.
Declaration
public event EventHandler<GridRowDropEventArgs> Drop
Event Type
| Type |
|---|
| System.EventHandler<GridRowDropEventArgs> |
Dropped
Raised after a row has been successfully dropped and committed.
Declaration
public event EventHandler<GridRowDroppedEventArgs> Dropped
Event Type
| Type |
|---|
| System.EventHandler<GridRowDroppedEventArgs> |