Hi!
Ok I've got a structure which looks like this:
Group A1 SubGroup B1 SubGroup C1 Leaf 1 Leaf 2 Leaf 3Group B2 SubGroup B2 SubGroup C2 Leaf 1 Leaf 2 Leaf 3Group C3 SubGroup B3 SubGroup C3 Leaf 1 Leaf 2 Leaf 3
So I want to do a search, scanning down my bands, actually for something that belongs in SubGroup C .
Let's say I have Group A1 selected, and I click Find... I select Band(2), then use GetRowEnumerator(DataRow) and search for the next available item, finding SubGroup C1.
This is fine, however, when I've got SubGroup C2 > Leaf 2 selected, I ONLY want to find rows after this.
As of yet, I haven't found an absolute property showing that Leaf 2 is in fact Row Number 10, SubGroup C3 is Row Number 14, therefore being after this row.
Using the VisibleIndex gives Row Number 1, ListIndex is also 1, but this is not useful. Also both SubGroup B1 and SubGroup B2 are indexed at 0, as they would be in the data source. In fact, Leaf 2 isn't even in the same band/collection as C3 so it's not related at all, and traversing through the entire grid would be more laborious than assigning a Row Number to each grid row.
Is there something I'm missing here?
Thanks, Tom
Hi Tom,
No, I don't think you are missing anything. The grid doesn't track any kind of absolute row index like that. It has no need of it, so it would be a waste for the grid to calculate it.
There's no easy method I found that will navigate the hierarchy in visible order like this, so I whipped up some sample code. I can't be sure it's 100% accurate in all cases, but it seems to work well in my testing. I'm attaching a small sample project here with the sample code so you can check it out.
Thanks Mike!
I wanted to avoid doing actual recursive traversal by using the Band Row Enumerator, but I guess it's the only way to do it. I shall translate and adapt for my solution, and of course, make it work in reverse for Find Previous, uhh.
Thanks again, Tom
Yeah, I was hoping not to have to write that code, either. :)
Let me know if you run into any problems writing the reverse-direction code.