Expand and Collapse Rows

  • 2 minutes to read

Vertical and property grid rows can have child rows. This topic describes how to collapse and expand rows in code.

How to: Expand or Collapse a Particular Row or All Rows

Use the BaseRow.Expanded property to specify whether a row is expanded or collapsed.

rowPicture.Expanded = false;

The image below shows how to specify the expand state in a designer.

To expand a row and all its child rows, pass the row to the VGridControlBase.FullExpandRow method.


To expand or collapse all rows, use the VGridControlBase.ExpandAllRows and VGridControlBase.CollapseAllRows methods.


How to: Expand or Collapse Specific Rows

To expand or collapse rows that meet a specific condition, enumerate rows and specify the expanded state. The following example collapses all rows except for the focused row and all its parent rows. See Tree Traversal for more details and examples.

vGridControl1.RowsIterator.DoOperation(new CollapseExceptSpecifiedOperation(vGridControl1.FocusedRow));

public class CollapseExceptSpecifiedOperation : RowOperation {
   BaseRow visibleRow;
   public CollapseExceptSpecifiedOperation(BaseRow visibleRow) : base() {
      this.visibleRow = visibleRow;
   public override void Execute(BaseRow row) {
      if (!row.HasAsChild(visibleRow))
         row.Expanded = false;
   public override bool NeedsFullIteration { get { return false; } }