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

How to: Enable Drag-and-Drop in the TableView

  • 6 minutes to read

This example demonstrates how to enable Drag-and-Drop functionality in the GridControl with a Table View. The DataViewBase.AllowDragDrop property is set to true.

Note

The GridControl ships with native drag-and-drop support starting from version 17.2. Use Drag-and-Drop Managers to enable drag-and-drop functionality in the previous versions.

The image below shows the result:

DragDropTableView

View Example

<Window x:Class="How_to_Table_View_Drag_and_Drop.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core" 
        xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/core" 
        xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
        xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <dxg:GridControl Name="gridControl" SelectionMode="Row">
            <dxg:GridControl.Columns>
                <dxg:GridColumn FieldName="ID" ReadOnly="True"/>
                <dxg:GridColumn FieldName="Name" ReadOnly="True"/>
                <dxg:GridColumn FieldName="Department" ReadOnly="True"/>
                <dxg:GridColumn FieldName="Position" ReadOnly="True"/>
            </dxg:GridControl.Columns>
            <dxg:GridControl.View>
                <dxg:TableView AutoWidth="True" AllowDragDrop="True"/>
            </dxg:GridControl.View>
        </dxg:GridControl>
    </Grid>
</Window>