This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyTreeListViewInfo.vb
78 lines (65 loc) · 3.32 KB
/
MyTreeListViewInfo.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
Imports DevExpress.XtraTreeList
Imports DevExpress.XtraTreeList.Columns
Imports DevExpress.XtraTreeList.Nodes
Imports DevExpress.XtraTreeList.ViewInfo
Imports System.Drawing
Namespace TreeListCellMerging
Public Class MyTreeListViewInfo
Inherits TreeListViewInfo
Public Sub New(ByVal fTreeList As TreeList)
MyBase.New(fTreeList)
End Sub
Protected Overrides Sub CalcRowCellsInfo(ByVal ri As RowInfo)
MyBase.CalcRowCellsInfo(ri)
If Not (CType(TreeList, MyTreeList)).OptionsView.AllowHorizontalMerge Then
Return
End If
If TreeList.OptionsSelection.EnableAppearanceFocusedRow Then
TreeList.OptionsSelection.EnableAppearanceFocusedRow = False
End If
For i As Integer = ri.Cells.Count - 1 To 1 Step -1
Dim prevDisplayText As String = GetCellDisplayText(ri, i - 1)
Dim currDisplayText As String = GetCellDisplayText(ri, i)
Dim args As New AllowMergeRowCellsEventArgs(ri, i, i - 1)
CType(TreeList, MyTreeList).RaiseMergeRowCells(args)
If args.Merge = DevExpress.Utils.DefaultBoolean.False Then
Continue For
End If
If (prevDisplayText = currDisplayText) OrElse (args.Merge = DevExpress.Utils.DefaultBoolean.True) Then
Dim prevCell As CellInfo = ri.Cells(i - 1)
Dim currCell As CellInfo = ri.Cells(i)
For j As Integer = ri.Lines.Count - 1 To 0 Step -1
Dim lineInfo As LineInfo = ri.Lines(j)
If lineInfo.Appearance IsNot PaintAppearance.VertLine Then
Continue For
End If
If lineInfo.Bounds.X = prevCell.Bounds.X + prevCell.Bounds.Width Then
ri.Lines.RemoveAt(j)
Exit For
End If
Next j
Dim mergedBounds As New Rectangle(prevCell.Bounds.X, prevCell.Bounds.Y, currCell.Bounds.Right - prevCell.Bounds.X, prevCell.Bounds.Height)
prevCell.SetBounds(mergedBounds, New System.Windows.Forms.Padding(0))
mergedBounds.Inflate(-1, -1)
prevCell.CalcViewInfo(GInfo.Cache, Point.Empty)
prevCell.EditorViewInfo.Bounds = mergedBounds
ri.Cells.RemoveRange(i - 1, 2)
ri.Cells.Insert(i - 1, prevCell)
MyBase.UpdateCellInfo(prevCell, prevCell.RowInfo.Node)
End If
Next i
End Sub
Protected Function GetCellDisplayText(ByVal ri As RowInfo, ByVal cellIndex As Integer) As String
Dim col As TreeListColumn = ri.Cells(cellIndex).Column
Return ri.Node.GetDisplayText(col)
End Function
Protected Function GetPrevNodeCellDisplayText(ByVal ri As RowInfo, ByVal cellIndex As Integer) As String
Dim prevNode As TreeListNode = ri.Node.PrevNode
If prevNode Is Nothing Then
Return String.Empty
End If
Dim col As TreeListColumn = ri.Cells(cellIndex).Column
Return prevNode.GetDisplayText(col)
End Function
End Class
End Namespace