Treeview BindingMode.TwoWay

Posted by: kbj on 30 December 2023, 9:09 am EST

  • Posted 30 December 2023, 9:09 am EST - Updated 30 December 2023, 9:16 am EST

    In the following form with a treeview named tv and a button Button1:

    Imports System.ComponentModel
    Imports C1.Win.TreeView
    Public Class Form1
        Private root As New classData
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            tv.SuspendLayout()
            root.children.Add(New classData)
            Text = root.children.Count
        End Sub
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            tv.BindingInfo.DataSource = root.children
            tv.BindingInfo.DataMember = "children"
            tv.BindingInfo.BindingMode = BindingMode.TwoWay
        End Sub
    End Class
    Public Class classData
        Public Property children As New BindingList(Of classData)
    End Class

    When adding the second record.

  • Posted 1 January 2024, 3:39 am EST

    Note: this only happens when

    tv.BindingInfo.BindingMode = BindingMode.TwoWay

  • Posted 1 January 2024, 10:50 pm EST

    Hi Kingman,

    Thank you for providing the sample code. We could see the behavior you mentioned on our end. We have shared the observations with the development team to get their insights on it and will let you know the updates as soon as possible.

    In the meantime, as a workaround, you can wrap the code to add the new node between the BeginUpdate and EndUpdate method calls. It resolved the behavior on our end. Please refer to the attached sample project for reference.

    Attachment: TreeView.TwoWayBinding.zip

    [Internal Tracking ID: C1WIN-31518]

    Best Regards,

    Kartik

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels