<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>
using System.Windows;
using System.Collections.ObjectModel;
namespace How_to_Table_View_Drag_and_Drop {
public partial class MainWindow : Window {
public class Employee {
public int ID { get; set; }
public string Name { get; set; }
public string Position { get; set; }
public string Department { get; set; }
public override string ToString() {
return Name;
}
}
public static class Stuff {
public static ObservableCollection<Employee> GetStuff() {
ObservableCollection<Employee> stuff = new ObservableCollection<Employee>();
stuff.Add(new Employee() { ID = 1, Name = "Gregory S. Price", Department = "", Position = "President" });
stuff.Add(new Employee() { ID = 2, Name = "Irma R. Marshall", Department = "Marketing", Position = "Vice President" });
stuff.Add(new Employee() { ID = 3, Name = "John C. Powell", Department = "Operations", Position = "Vice President" });
stuff.Add(new Employee() { ID = 4, Name = "Christian P. Laclair", Department = "Production", Position = "Vice President" });
stuff.Add(new Employee() { ID = 5, Name = "Karen J. Kelly", Department = "Finance", Position = "Vice President" });
stuff.Add(new Employee() { ID = 6, Name = "Brian C. Cowling", Department = "Marketing", Position = "Manager" });
stuff.Add(new Employee() { ID = 7, Name = "Thomas C. Dawson", Department = "Marketing", Position = "Manager" });
stuff.Add(new Employee() { ID = 8, Name = "Angel M. Wilson", Department = "Marketing", Position = "Manager" });
stuff.Add(new Employee() { ID = 9, Name = "Bryan R. Henderson", Department = "Marketing", Position = "Manager" });
stuff.Add(new Employee() { ID = 10, Name = "Harold S. Brandes", Department = "Operations", Position = "Manager" });
stuff.Add(new Employee() { ID = 11, Name = "Michael S. Blevins", Department = "Operations", Position = "Manager" });
stuff.Add(new Employee() { ID = 12, Name = "Jan K. Sisk", Department = "Operations", Position = "Manager" });
stuff.Add(new Employee() { ID = 13, Name = "Sidney L. Holder", Department = "Operations", Position = "Manager" });
stuff.Add(new Employee() { ID = 14, Name = "James L. Kelsey", Department = "Production", Position = "Manager" });
stuff.Add(new Employee() { ID = 15, Name = "Howard M. Carpenter", Department = "Production", Position = "Manager" });
stuff.Add(new Employee() { ID = 16, Name = "Jennifer T. Tapia", Department = "Production", Position = "Manager" });
stuff.Add(new Employee() { ID = 17, Name = "Judith P. Underhill", Department = "Finance", Position = "Manager" });
stuff.Add(new Employee() { ID = 18, Name = "Russell E. Belton", Department = "Finance", Position = "Manager" });
return stuff;
}
}
public MainWindow() {
InitializeComponent();
gridControl.ItemsSource = Stuff.GetStuff();
}
}
}
Imports System.Windows
Imports System.Collections.ObjectModel
Namespace How_to_Table_View_Drag_and_Drop
Partial Public Class MainWindow
Inherits Window
Public Class Employee
Public Property ID() As Integer
Public Property Name() As String
Public Property Position() As String
Public Property Department() As String
Public Overrides Function ToString() As String
Return Name
End Function
End Class
Public NotInheritable Class Stuff
Private Sub New()
End Sub
Public Shared Function GetStuff() As ObservableCollection(Of Employee)
Dim stuff_Renamed As New ObservableCollection(Of Employee)()
stuff_Renamed.Add(New Employee() With { _
.ID = 1, _
.Name = "Gregory S. Price", _
.Department = "", _
.Position = "President" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 2, _
.Name = "Irma R. Marshall", _
.Department = "Marketing", _
.Position = "Vice President" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 3, _
.Name = "John C. Powell", _
.Department = "Operations", _
.Position = "Vice President" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 4, _
.Name = "Christian P. Laclair", _
.Department = "Production", _
.Position = "Vice President" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 5, _
.Name = "Karen J. Kelly", _
.Department = "Finance", _
.Position = "Vice President" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 6, _
.Name = "Brian C. Cowling", _
.Department = "Marketing", _
.Position = "Manager" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 7, _
.Name = "Thomas C. Dawson", _
.Department = "Marketing", _
.Position = "Manager" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 8, _
.Name = "Angel M. Wilson", _
.Department = "Marketing", _
.Position = "Manager" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 9, _
.Name = "Bryan R. Henderson", _
.Department = "Marketing", _
.Position = "Manager" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 10, _
.Name = "Harold S. Brandes", _
.Department = "Operations", _
.Position = "Manager" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 11, _
.Name = "Michael S. Blevins", _
.Department = "Operations", _
.Position = "Manager" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 12, _
.Name = "Jan K. Sisk", _
.Department = "Operations", _
.Position = "Manager" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 13, _
.Name = "Sidney L. Holder", _
.Department = "Operations", _
.Position = "Manager" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 14, _
.Name = "James L. Kelsey", _
.Department = "Production", _
.Position = "Manager" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 15, _
.Name = "Howard M. Carpenter", _
.Department = "Production", _
.Position = "Manager" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 16, _
.Name = "Jennifer T. Tapia", _
.Department = "Production", _
.Position = "Manager" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 17, _
.Name = "Judith P. Underhill", _
.Department = "Finance", _
.Position = "Manager" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 18, _
.Name = "Russell E. Belton", _
.Department = "Finance", _
.Position = "Manager" _
})
Return stuff_Renamed
End Function
End Class
Public Sub New()
InitializeComponent()
gridControl.ItemsSource = Stuff.GetStuff()
End Sub
End Class
End Namespace