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
1800
Binding nested list of objects
posted

Hi,

I have a nested list of objects. I need the data to be displayed in hierarchial manner.

I have a list of objects, lets say list A, which has IList(of  B) (Generic List) as one of its properties and IList(of B) contains IList (of C). What should i do to display the data in hierarchial way ?

Couple of tradeoffs that i have is, IList(of B) and IList(of C) might not have the same columns and i'm trying to use BindingList(of A). Still i get only parent list and not the child ones'

Any help is appreciated!

Thanks.,

Parents
  • 469350
    Suggested Answer
    Offline posted

    If you have a list of A and one of the properties of the A object is a list of some other object, then you don't have to do anything. SImply bind the grid to the list of A objects and the B object list will display as a child band.

    I would recommend using BindingList rather than List, though. List will not allow you to add new rows and it will not update the grid when the data changes.

    Also, you might have to use List rather than just IList. It think the BindingManager might not recognize IList as a valid chaptered property.

Reply Children