StrataFrame Forum

TreeView Data Binding Guidance

http://forum.strataframe.net/Topic3826.aspx

By Chris Crabtree - 10/23/2006

I have a BO something like this:

  • StrategyID
  • ParentStrategyID
  • Name
  • Description

Actually, I should say I will have a BO something like this, but anyway...would love to do one of two things with this data:

  1. Allow the user to select a particular node on the tree so I can grab the StrategyID from it.
  2. Allow the user to edit the tree in place.

I understand that #2 is more difficult than #1, and in fact just having an easy way to accomplish #1 would be great. #2 is not strictly necessary for my application, but would just be a nice-to-have.

By the way, I usually create a root node that has itself as its parent so that all the first-level nodes can have a real parent to point to and that way I don't have to deal with null parents and all that. But I'm open to suggestions on any of this...

Thanks!

By StrataFrame Team - 10/24/2006

Generally, with treeviews, we build the tree manually by iterating through the business object(s) containing the data for the node.  We put the primary key or a NodeInfo structure (that contains the pk and a node type flag) in the Tag of each node that we place in the tree.  Then, we handle the AfterSelect event of the treeview and depending upon the node type flag in the structure in the tag, we process more information, like show a panel on the right that contains detailed information about the node.  As for editing in place, you will need to set the LabelEdit property to True and handle the BeforeLabelEdit (optional) and the AfterLabelEdit event to seek to the record in the business object and change the value.
By Chris Crabtree - 11/15/2006

By the way, I just wanted to share that I ended up using a TreeList from Developer Express which had explicit support for a self-referencing table to implement a parent/child relationship and in-place editing.

I just used the SF BusinessBindingSource and set the tree's KeyFieldName and ParentFieldName values appropriately. Added the RootValue for a dummy root parent row and was basically done.

Very nice.