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
320
Hierarchical generic lists and WinGrid
posted

Hi

I have a hierarchical generic list which I would like to bind to a WinGrid.

I have:

A grouping class for my data List<GroupClass> gc

gc has a children property List<GroupClass> gc

So what i am trying to do is to bind this hierarchy to the WinGrid that would allow users to drill down the levels of the hierarchy.

This would be the first step.

The second is that there are actually 2 other classes. One that holds TIME in the exact same way as the group class: List<TimeClass> tc with children List<TimeClass>.

gc and tc have an infinte depth. for example the tc can have levels like 2009 > Quarter 1 > February > Day etc etc

The third class holds values. <List>ValueClass vc which has as properties gc.ID and tc.ID and a VALUE.

So i would like to be able to drill into the groups, then into the time for the groups down n number of levels to get the vc.VALUE.

 

Is something like this achievable, are there some pointers that you can give me to maybe get something close to what I am trying to achieve. Does this even make sense?

I understand how to bind data using a dataset and building datarelations. but i would like to bind my class with it's hierarchies directly.

Thanks

 

 

 

 

 

 

Parents
  • 469350
    Suggested Answer
    Offline posted

    Hi,

    If you are going to bind the grid to some custom objects like this, I recommend using BindingList<T>, rather than List<T>. BindingList is specifically designed for DataBinding and it will work better and send better notifications to the grid when data is added or removed from the list.

    Regarding the rest of your question, you kinda lost me about half way through, so I'm not really clear on the data structure you want. But the way it works is that if you bind the grid to a List<T> or BindingList<T>, then each item in the list is a row in the grid and the properties of the object type <T> become the grid column.

    To display child data, the object class <T> has to expose a public property that returns another List<T> or BindingList<T>.

Reply Children