-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.vb
45 lines (40 loc) · 2.37 KB
/
Form1.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Views.Tile
Namespace Reorder
Public Partial Class Form1
Inherits DevExpress.XtraBars.ToolbarForm.ToolbarForm
Public Sub New()
InitializeComponent()
tileView1.OptionsKanban.Groups.Add(New KanbanGroup() With {.Caption = "Group 0", .GroupValue = 0})
tileView1.OptionsKanban.Groups.Add(New KanbanGroup() With {.Caption = "Group 1", .GroupValue = 1})
tileView1.OptionsKanban.Groups.Add(New KanbanGroup() With {.Caption = "Group 2", .GroupValue = 2})
tileView1.OptionsKanban.Groups.Add(New KanbanGroup() With {.Caption = "Group 3", .GroupValue = 3})
' Sort by the "IndexInGroup" column
colIndexInGroup.SortOrder = DevExpress.Data.ColumnSortOrder.Ascending
gridControl1.DataSource = DataHelper.GetData()
AddHandler tileView1.BeforeItemDrop, AddressOf TileView1_BeforeItemDrop
End Sub
Private Sub TileView1_BeforeItemDrop(ByVal sender As Object, ByVal e As BeforeItemDropEventArgs)
e.Handled = True
' Leave data source indexes as is
e.NewListSourceRowIndex = e.ListSourceRowIndex
Dim view = TryCast(sender, TileView)
Dim column = view.Columns("IndexInGroup")
' Assign new IndexInGroup column values for all cards
' that are already in the target group
If e.NewGroupRowHandle <> GridControl.InvalidRowHandle Then
Dim childRowCount As Integer = view.GetChildRowCount(e.NewGroupRowHandle)
For n As Integer = 0 To childRowCount - 1
Dim rowHandle As Integer = view.GetChildRowHandle(e.NewGroupRowHandle, n)
' Skip the TargetIndexInGroup - this index must belong to the dragged card
Dim index As Integer = If(n >= e.TargetIndexInGroup, n + 1, n)
view.SetRowCellValue(rowHandle, column, index)
Next
End If
' Assign the TargetIndexInGroup value to the "IndexInGroup" cell of the dragged card
view.SetRowCellValue(e.RowHandle, column, e.TargetIndexInGroup)
' Assign the new "colGroupId" column value to the dragged card
view.SetRowCellValue(e.RowHandle, view.ColumnSet.GroupColumn, e.NewGroupColumnValue)
End Sub
End Class
End Namespace