[Expand]General Information
[Collapse]WinForms Controls
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications, and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Collapse]Vertical Grid
   [Expand]Binding to Data
   [Collapse]Data Layout: Records, Rows and Cells
      Scrolling and Focusing Rows
      Using the Rows Iterator
      Expanding and Collapsing Rows
    [Expand]Customization Form
     Data Layout: Records, Rows, and Cells
   [Expand]Data Editing and Validation
    Formatting Values
   [Expand]Drag and Drop
   [Expand]Appearance and Custom Painting
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]End-User Capabilities
    Hit Information
    Batch Modifications
   [Expand]Member Tables
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Member Tables
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Map Control
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Sunburst Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Expanding and Collapsing Rows

Each row in a vertical grid control (VGridControl or PropertyGridControl) can have a number of child rows, so rows can be expanded and collapsed to show or hide their children respectively. This topic describes the means by which they can be collapsed or expanded.

Expanded Collapsing and Expanding Rows

Rows in the vertical grids inherit the ability to contain child rows and to be the children of other rows from their common ancestor - the BaseRow class. Amongst other settings, this class declares the BaseRow.Expanded property which can be used to collapse or expand rows and to determine their current state. To expand a row, you must set its BaseRow.Expanded property to true, setting it to false will collapse the row. The image below shows how to change the expanded state of a row at design time.

To change the expanded state for a specific row at runtime you need to obtain its row object and modify the BaseRow.Expanded property value.

The code line below shows how to collapse the rowMain row.

Note that the BaseRow.Expanded row property value doesn't affect the expanded state of a row's child rows. For instance, expanding a row that has collapsed child rows will not expand its children. So, if you collapse a row, all child rows will retain their expanded state and will appear in these states again when their parents are expanded.

In addition to expanding and collapsing individual rows, the vertical grid enables you to expand a row together with all of its child rows. This can be performed using the VGridControlBase.FullExpandRow method that requires a row as the parameter.

The line of code below demonstrates how to use the VGridControlBase.FullExpandRow method to expand the rowMain row together with all its children.

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

When designing applications using the vertical grids you can expand or collapse rows which satisfy a specific condition. This can be performed by means of the Rows Iterator technology introduced by the vertical grid control. This technology provides an easy way of traversing through control rows and performing operations on them. Please refer to the Using the Rows Iterator topic for more information regarding this.

The following sample code is used to collapse all rows that do not contain the focused row as the child. So as a result only rows that are parents of the focused row are expanded, to implement this the new operation class used by the rows iterator is declared and its instance is passed to the VGridRowsIterator.DoOperation method of the iterator.

Is this topic helpful?​​​​​​​