Back to Devexpress

DXDragEventArgs.GetData<T>() Method

windowsforms-devexpress-dot-utils-dot-dragdrop-dot-dxdrageventargs-dot-getdata-1.md

latest3.4 KB
Original Source

DXDragEventArgs.GetData<T>() Method

Returns the data elements being dragged.

Namespace : DevExpress.Utils.DragDrop

Assembly : DevExpress.Utils.v25.2.dll

NuGet Packages : DevExpress.Utils, DevExpress.Wpf.Core

Declaration

csharp
public T GetData<T>()
vb
Public Function GetData(Of T) As T

Type Parameters

NameDescription
T

The data type.

|

Returns

TypeDescription
T

The data type.

|

Remarks

The actual data type depends on the source control.

  • For a grid control - an array of row handles.
cs
// The source control is a grid.
int[] rowHandles = e.Data as int[];
int[] rowHandles1 = e.GetData<int[]>();
  • For a tree list - a list of the nodes.
cs
// The source is a tree list.
List<TreeListNode> nodeList = e.Data as List<TreeListNode>;
List<TreeListNode> nodeList1 = e.GetData<List<TreeListNode>>();
  • For a list box control - a list of the list box items.
cs
// The source control is a list box.
List<object> items = e.Data as List<object>;
List<object> items1 = e.GetData<List<object>>();
// If the list box is not bound to a data source (see the Items property),
// the event argument contains string representations of data items.
string item0 = items[0] as string;
// If the list box is bound to a data source (see the DataSource property),
// the actual type depends on the data source.
DataRowView dataRowView0 = items[0] as DataRowView;

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the GetData<T>() method.

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.

drag-drop-grid-rows-to-treelist/CS/DragAndDropRows/Form1.cs#L68

csharp
private void OnDragDrop(object sender, DevExpress.Utils.DragDrop.DragDropEventArgs e) {
    var indexes = e.GetData<IEnumerable<int>>();
    if(indexes == null)

drag-drop-grid-rows-to-treelist/VB/DragAndDropRows/Form1.vb#L67

vb
Private Overloads Sub OnDragDrop(ByVal sender As Object, ByVal e As DragDropEventArgs)
    Dim indexes = e.GetData(Of IEnumerable(Of Integer))()
    If indexes Is Nothing Then Return

See Also

DXDragEventArgs Class

DXDragEventArgs Members

DevExpress.Utils.DragDrop Namespace