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
30
Outlook style treeview
posted

Hi -

I am binding a collection of objects to a tree view having a view style of Outlook Express.  The objects have a group name property, a name property and an ID property.  I would like to use the group name as the root node and then have all other nodes with the same group name nested as child nodes.

I set the rootcolumnset proerty on the treeview to point at the autogenerated columnset.  All I end up with is a flat list with no heirarchical display.  Any ***ance is appreciated.

Parents
  • 69832
    Verified Answer
    Offline posted

    In the case where you are binding to a business object, the thing that makes a second level appear is a property of type IList, BindingList, etc., exposed by the object that the root level nodes represent. For example, let's say you had an object named 'Group', and you bind the tree to a BindingList<Group>:

    public class Group
    {
        public string Name { get; }
        public List<GroupMembers> Members { get; }
    }

    public class GroupMembers
    {
        public string Name { get; }
    }

    Each Group object would have a collection of GroupMember objects, and you would see child nodes for each member of the Group object's Members collection.

    The OutlookExpress view style is typically used to present a recursive data relationship. An example of this would be a DataSet with a DataRelation defined such that a row has a reference to another row, which has a reference to another row, etc., thus creating an n level hierarchy. A real world example of this would be a forum, where the first posting in a thread has an article ID, and the second and subsequent ones have an ID that relates to the article ID, and also to a parent post in the thread. This is what you see in OutlookExpress; you can take a look at the 'UltraTree NewsgroupReader' sample, which is included with the SDK, to see how all that is accomplished.

    The reason I mention this is because if the data you are binding to is not recursively related, you might want to consider using the Grid ViewStyle instead.

Reply Children
No Data