Expand / Collapse SelfReference Hierarchy

2 posts, 0 answers
  1. Arun Kumar
    Arun Kumar avatar
    60 posts
    Member since:
    Nov 2009

    Posted 30 Jun 2011 Link to this post

    Hi All,

    I want to expand / collapse all rows on button click event. I tried the dgv.MasterTemplate.ExpandAll() 
    and dgv.MasterTemplate.CollapseAll() functions but none of them work. 

    I have around 8000 rows and 6 levels. How do I do that?

    Also I noticed, I expanded one group that has more than 2000 rows will take some seconds to expand and then I expand another one which has only 2 rows that also take same time of previous group. If I collapse previous group and then expand the second one it expanded quickly.  Is this normal behavior?

    Thanks in advance
  2. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 30 Jun 2011 Link to this post

    Hello,

    To expand and collapse all rows, you can use the following code:

    Expand
    radGridView1.GridElement.BeginUpdate();
    foreach (GridViewDataRowInfo row in radGridView1.Rows)
    {
        row.IsExpanded = true;
    }
    radGridView1.GridElement.EndUpdate();

    Collapse
    radGridView1.GridElement.BeginUpdate();
    foreach (GridViewDataRowInfo row in radGridView1.Rows)
    {
        row.IsExpanded = false;
    }
    radGridView1.GridElement.EndUpdate();

    With regard to the performance issue that you've mentioned, there is a current known issue in this area. For more information on this, please take a look at this forum thread

    Hope that helps
    Richard
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top