Expanding And Collapsing Rows
- 2 minutes to read
Every row in the ExpressVerticalGrid control can have a number of child rows, so rows can be expanded and collapsed to show and hide their children respectively.
You can set the expanding state at design time or runtime.
Setting Expanding State at Design Time
To set the default expanding state that the desired row has, the first time the user runs the application use the TcxCustomRow.Expanded property in the Object Inspector.
If you set this property to True the desired row will be expanded. Otherwise it will be collapsed.
Setting Expanding State at Runtime
To expand or collapse the desired row at runtime you can use three members of the TcxCustomRow class: the TcxCustomRow.Expanded property and the TcxCustomRow.Expand / TcxCustomRow.Collapse methods.
Assigning the TcxCustomRow.Expanded property True or False values is similar to invoking the TcxCustomRow.Expand and TcxCustomRow.Collapse methods respectively.
Note
there is one exception for this property, it is not possible to expand or collapse all of the subtrees of the row, where as with the mentioned methods if they are provided with the True argument all of the subtrees of the desired row will be expanded or collapsed.
//...
// Expand or collapse the desired row without expanding or collapsing its subtrees
rowPerformance_Attributes.Expanded := True; //or
rowPerformance_Attributes.Expand(False); // the same behavior
//...
rowPerformance_Attributes.Expanded := False; //or
rowPerformance_Attributes.Collapse(False); // the same behavior
// Expand or collapse the desired row along with expanding or collapsing its subtrees
rowPerformance_Attributes.Expand(True);
//or
rowPerformance_Attributes.Collapse(True);
Besides the row members there are two more methods for the vertical grid object TcxCustomVerticalGrid.FullExpand and TcxCustomVerticalGrid.FullCollapse you can use for bulk operations that is all parents at any level will be expanded or collapsed.
//Delphi
//...
// Expand or collapse all of the parent rows in the grid
cxDBVerticalGrid.FullExpand;
cxDBVerticalGrid.FullCollapse;