I'm displaying a hierarchy of data that can be 5 levels deep. I'd like to persist/restore the expand/collapse state of the hierarchy when the user closes and reopens the form. My rule of thumb will be that if any data at level n is expanded, then level n throughout the grid is expanded, so it's data independent.
Can you tell me the best way to satisfy this requirement? Do I need to iterate the whole grid (which worse case is 150 rows)? What rules do I need to apply when I redraw. I.e. if I say a row at level 4 is expanded, does that automatically expand level 3?
Thanks.
Hi,
You will need to iterate the rows collections of the grid recursively. There's no other way to get the state of each row.
To expand all of the rows again, you can probably make use of the GetRowEnumerator method on the Rows collection. This method lets you specify the lowest level band you want to loop to. So it will return all rows in the grid up to level X. So you can just loop through the rows and set Expanded on each row to true, without having to write your own recursion routine.
Actually, now that I think about it, you can probably use the GetRowEnumerator or another method on the Rows collection like GetAllNonGroupByRows to avoid writing recursive routines when determining the bands to expand.