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
25
How to access child rows of WinGrid bound to hierarchical data?
posted

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

Parents
  • 25
    posted

    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?:)

Reply Children