Anyone have experience binding a DynamicBindingListBase<> with child items to a TreeView in Winforms???

Anyone have experience binding a DynamicBindingListBase<> with child items to a TreeView in Winforms???

Old forum URL:

cwinkelmann posted on Tuesday, March 27, 2012

I could really use a code example of using CSLA with the TreeView in WinForms...

I have a collection of BusinessBase objects each with a child collection of the same type BusinessBase (recursive relations) from a table in SQL. I can load them On Demand, but when updating it is a little tricky. It seems the first time the child object is updated it will send the proper messages to the parents all the way up the chain, but any subsequent updates do not fire.

I suspect this is because the update creates a clone of the object from the data portal as it is sent to the update methods on the DAL. I'm not sure how the user interface is to rebind to the new object returned from the Data Portal. It seems like all the collections are simply in limbo...

Could someone explain this behavior or show some example code where CSLA binds to a TreeView???

Thanks Greatly! :-)

tiago replied on Tuesday, March 27, 2012

TreeView has no DataSource property because it can't use ordinary tabular data. On WebForms the TreeView can indeed DataBind if your bound object implements IHierarchicalData. That interface doesn't exist on WinForms. So there is no DataBinding for TreeView under WinForms.


By the way, the TreeView in ASP.NET is meant for ReadOnly objects. My TreeView has ObjectID on the Tag property. When I need to change something on the node (name, ParentObjectID, etc), I pick up ObjectID and use ObjectNodeEdit (EditableRoot). When I need to add or to remove a node, I do the same.

cwinkelmann replied on Wednesday, March 28, 2012

I am familiar with lots of complexities with the tree view, but it just seemed overwhelming to get the standard MS VS TreeView control to support databinding. Unfortunately I am not doing the development in ASP.Net or WPF. I have been forced to learn some WPF because of formatting issues of a User Control that is able to grow and shrink depending on the contents... Unfortunately there is way too much code base to convert to WPF now. That would be a completely new project and I am pretty familiar with Winforms.

I have started examining a few 3rd party control libraries like DevExpress and others. I think those have great potential and I'll report back my findings on this thread for the use of other developers as soon as I can. I think the controls are UltraTree and TreeList. There are also enhanced GridViews that can display hierarchical data which is the ultimate goal. However an editable TreeView UI is the most intuitive for my users. Less clicks, more data displayed as it is naturally organized....

Once again! Thanks greatly!

Copyright (c) Marimer LLC