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
1369
Get Specific Band Rows
posted

Hi,

I am using hierarchical grid first time.

I have multiple bands in my grid. I don't have exactly idea how many bands are. I want to get the rows of specific band by providing its name or index. At the moment I cannot find any rows collection under band.

I don't want to iterate through by looping.

Another problem:

I want first parent row index in case of multiple bands. If my selected row is in band four and row index is 4 but I need band[0] row index.

  • 95
    posted

    Grid.ActiveRow.ParentCollection.Count

  • 95
    Suggested Answer
    posted

    Grid.ActiveRow.ParentCollection.Count

    use this this will return the row count

  • 17259
    Verified Answer
    Offline posted

    There are no rows under a band. You can get the child rows of a row by row.ChildBands[index].Rows.

    If you want all the rows of a band, use:

    grid.Rows.GetRowEnumerator(GridRowType.DataRow, bandIndex, null)

    For your second problem, add this code somewhere and you can use row.GetRootRow():

    namespace Infragistics.Win.UltraWinGrid

    {

    public static class UltraGridRowExtension

    {

    public static UltraGridRow GetRootRow(this UltraGridRow row)

    {

    if (row.ParentRow != null)

    {

    if (row.ParentRow.ParentRow != null)

    return GetRootRow(row.ParentRow);

    else

    return row.ParentRow;

    }

    else

    return null;

    }

    }

    }