Treeview Refresh

2 posts, 1 answers
  1. Nick Jones
    Nick Jones avatar
    18 posts
    Member since:
    Jun 2009

    Posted 15 Mar 2011 Link to this post

    Hi, I'm having an issue refreshing the data in my treeview.  Here is the treeview.

    'Build Tree View
    Private Sub BuildtvOrgan()
        tvOrgan.RelationBindings.Add(New RelationBinding("CompanyDepts", Me.DepartmentBindingSource))
        tvOrgan.RelationBindings.Add(New RelationBinding("Department_Employee", Me.EmployeeBindingSource))
        tvOrgan.RelationBindings.Item(0).DisplayMember = "DeptName"
        tvOrgan.RelationBindings.Item(0).ValueMember = "id"
        tvOrgan.RelationBindings.Item(0).DataSource = DepartmentBindingSource
        tvOrgan.RelationBindings.Item(1).DisplayMember = "FName"
        tvOrgan.RelationBindings.Item(1).ValueMember = "id"
        tvOrgan.RelationBindings.Item(1).DataSource = EmployeeBindingSource
        tvOrgan.DataSource = CompanyBindingSource
        tvOrgan.ValueMember = "id"
        SetImages(tvOrgan.Nodes)
        tvOrgan.ExpandAll()
    End Sub

    Now, when I modify the underlying data the treeview doesn't change.  It does change if I add data to the underlying tables.  If I add a new Company.Department.Employee to the datatables the treeview updates, with an expandall().  However if I change department A to now be in department C instead of B it doesn't move until I reload the app.  Any idea's anyone?  How can I get the treeview to show changes made to the datasource.

    Thanks
  2. Answer
    Nick Jones
    Nick Jones avatar
    18 posts
    Member since:
    Jun 2009

    Posted 15 Mar 2011 Link to this post

    Think I have resolved this.  treeview.BeginUpdate and Endupdate.  Seems to have fixed it.

  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top