Posted 12 February 2023, 6:53 am EST
When adding an item into a KeyField/ParentKeyField bound treeview, the new child item always shows up at the end of its group. In the following example, is there a way to have the child (2.2) show up between its two siblings (2.1 & 2.3)?
Imports System.ComponentModel
Imports C1.Win.TreeView
Public Class Form1
Private bl As New BindingList(Of classData)
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
bl.Add(New classData("0", "1"))
bl.Add(New classData("0", "2"))
bl.Add(New classData("2", "2.1"))
bl.Add(New classData("2", "2.3"))
bl.Add(New classData("0", "3"))
Dim column = New C1TreeColumn()
column.DisplayFieldName = "title"
column.HeaderText = "title"
C1TreeView1.Columns.Clear()
C1TreeView1.Columns.Add(column)
C1TreeView1.BindingInfo.KeyField = "title"
C1TreeView1.BindingInfo.ParentKeyField = "parent"
C1TreeView1.BindingInfo.DataSource = bl
End Sub
Private Sub Form1_MouseClick(sender As Object, e As MouseEventArgs) Handles Me.MouseClick
bl.Insert(3, New classData("2", "2.2"))
End Sub
End Class
Public Class classData
Public Property parent As String
Public Property title As String
Public Sub New(parent As String, title As String)
Me.parent = parent
Me.title = title
End Sub
End Class