I have a UltraDataGrid that I've bound to an UltraDataSource. My data source has two levels.
I am having trouble accessing the child bands through the grid. I know that myDataGrid.Rows exposes a RowsCollection for band 0 (the top-level band). What I would like to do is get a RowsCollection for any of the child bands that I have defined in my UltraDataSource.
I have tried code like this, but it still only gives me the top-level rows:
foreach (UltraGridBand band in this.detectionUltraGrid.DisplayLayout.Bands){ foreach (UltraGridRow row in band.Layout.Rows) { // This RowsCollection is the top level foreach (UltraGridCell cell in row.Cells) { if (cell.Value == DBNull.Value) { cell.Hidden = true; } } }
}
How do I get to the child rows?
Thanks,Ben
With some help, I think I figured out one way to access the child bands:
foreach (UltraGridRow row in this.myUltraGrid.Rows){ foreach (UltraGridChildBand childBand in row.ChildBands) { foreach (UltraGridRow childRow in childBand.Rows) { foreach (UltraGridCell cell in childRow.Cells) { if (cell.Value == DBNull.Value) { cell.Hidden = true; } } } } }
Is there a better way? With less nesting?:)
If all you're trying to do is hide a cell if it's value is null, your best option is to simply use the InitializeRow event and check to see if the cell's Value is null there, and possibly that its Band's Key is what you're looking for.
-Matt