Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
270
How to refresh wintree after datasource changed
posted

 Hi!

I'm usin' wintree not long ago. So - I bind a tree to List<T> collection. When I add new element to list I do not see it in a tree.

So I have to rebind it completely - it's so ugly ((

This is the code that I use now?

            List<Organization> organizationList = (this.organizationTree.DataSource as List<Organization>);
            organizationList.Add(newOrganization);
            this.organizationTree.DataSource = null;
            this.organizationTree.DataSource = organizationList;

So u see I wanna to know the way to make it natural way - "just modify the collection and see the results immediatly in tree".

Am I askin' too much???

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

     Hi, 

    The problem here is that a List implements the IList interface instead of IBindingList. IList doesn't have any way to notify bound controls that data has been added. The easiest thing for you to do in this case would be to use a BindingList<Organization> as your tree's data source, rather than a List<Organization>.

Children