Home Forums WinForms controls Xceed Grid for WinForms Programatically close/expand groups? Reply To: Programatically close/expand groups?

User (Old forums)
Member
Post count: 23064

Mate,

If I am writing something I wouldwrite like following

Just Drag and Drop Button on Form and attach Click Event to it.

Write a rec method to the job for you..

THis will handle collapse or expand anything upto any level..

private void button1_Click(object sender, EventArgs e)
    {
        bool collapse = (String.Compare(button1.Text, “Collapse All”, true) == 0);
        CollapseOrExpand(collapse,gridControl1.Groups);
        button1.Text = (collapse) ? “Expand All” : “Collapse All”;
    }

    private void CollapseOrExpand(bool collapse, ReadOnlyGroupList group)
    {
       foreach(Group currentgroup in group)
       {
           if (currentgroup.Groups.Count > 0)
           {
               CollapseOrExpand(collapse, currentgroup.Groups);
           }
           else
           {
               currentgroup.Collapsed = collapse;
           }
       }
    }

 

Imported from legacy forums. Posted by NR (had 380 views)