I have an ultragrid with two bands. Band 0 and Band 1. How to loop only through the parent rows i.e only through the band 0 and find the cell value in that band 0 so that I can compare that value ? Am using the InitializeRow Event.
You don't need an event - you can just loop right after you set the grid's DataSource.
I guess you could also use the InitializeLayout event.
Got ur point.
What is the best event to use, to loop through all the band 0 rows after the grid is loaded ?
If you want to add spacing under a row based on that values in that row, then you can use the InitializeRow event. But the event fires for each row. So there's no reason to loop, unless maybe you want to loop through the child rows when the parent row is initialized.
But there's no good reason to loop through the entire rows collection inside InitializeRow, and doing so would be very inefficient.
What I wanted to do is loop through the parent rows and based on the column value in the parent row I would like to insert a row spacing under that band of rows.
Ex:
Date Type
02/23 A //ParentRow
-- Childrows
02/23 B
02/24 A
My output Should be:
Row Space Here
Hi,
This code is very inefficient. The InitializeRow event fires for each row in the grid and may fire multiple times. So it's a bad idea to loop through the rows collection from inside this event. What exactly are you trying to do here that you want to loop?
To answer your question, the Rows collection (grid.Rows) has a GetRowsEnumartor method that lets you specify a particular band and ignores rows in any other bands. But it's still very inefficient (and usually unnecessary) to loop through the row from within the InitializeRow event.