Edit this page

Expanding all rows

In order to expand all rows in RadGridView you have to iterate through them and set the IsExpanded property to true. The following code snippet demonstrates how to achieve it. You can call the method when the grid is loaded or when you click a button :

void ExpandAllRows(GridViewTemplate template, bool expanded)
{
    foreach (GridViewRowInfo row in template.Rows)
    {
        row.IsExpanded = expanded;
    }
    if (template.Templates.Count > 0)
    {
        foreach (GridViewTemplate childTemplate in template.Templates)
        {
            ExpandAllRows(childTemplate, true);
        }
    }
}

Private Sub ExpandAllRows(ByVal template As GridViewTemplate, ByVal expanded As Boolean)
    For Each row As GridViewRowInfo In template.Rows
        row.IsExpanded = expanded
    Next
    If template.Templates.Count > 0 Then
        For Each childTemplate As GridViewTemplate In template.Templates
            ExpandAllRows(childTemplate, True)
        Next
    End If
End Sub

See Also