Back to Devexpress

BaseRow.Expanded Property

windowsforms-devexpress-dot-xtraverticalgrid-dot-rows-dot-baserow-a6f2d03f.md

latest5.0 KB
Original Source

BaseRow.Expanded Property

Gets or sets a value specifying whether the current row is expanded.

Namespace : DevExpress.XtraVerticalGrid.Rows

Assembly : DevExpress.XtraVerticalGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.VerticalGrid

Declaration

csharp
[DefaultValue(true)]
[DXCategory("Appearance")]
[XtraSerializableProperty]
public virtual bool Expanded { get; set; }
vb
<DXCategory("Appearance")>
<DefaultValue(True)>
<XtraSerializableProperty>
Public Overridable Property Expanded As Boolean

Property Value

TypeDefaultDescription
Booleantrue

true if the current row is expanded; otherwise false.

|

Remarks

The Expanded property is only for parent rows (i.e. for rows containing child rows). You can determine whether a particular row has children by using the BaseRow.HasChildren property. Set a parent’s row Expanded property to true to display its child rows. If set to false , the current parent row is collapsed and its child rows hidden.

Example

The following sample code expands all collapsed parent rows at the root level and collapses expanded ones. The BaseRow.Expanded property is used for this purpose. The collection of root level rows is accessed via the VGridControlBase.Rows property. The BaseRow.HasChildren property is used to determine whether a row is a parent one and can be expanded or collapsed.

The image below displays the look & feel of a grid control before and after execution of the sample code.

csharp
foreach (BaseRow currRow in vGridControl1.Rows) {
    // collapsing expanded parent rows or expanding collapsed ones
    if (currRow.HasChildren) currRow.Expanded = !currRow.Expanded;
}
vb
Dim CurrRow As BaseRow
For Each CurrRow In VGridControl1.Rows
' collapsing expanded parent rows or expanding collapsed ones
    If CurrRow.HasChildren Then CurrRow.Expanded = Not CurrRow.Expanded
Next

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Expanded property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-propertygrid-filter-object-properties/CS/Form1.cs#L16

csharp
this.propertyGridControl1.SelectedObject = this.propertyGridControl1;
this.propertyGridControl1.GetRowByFieldName("Size").Expanded = true;
this.propertyGridControl1.GetRowByFieldName("Location").Expanded = true;

winforms-propertygrid-filter-object-properties/VB/Form1.vb#L14

vb
propertyGridControl1.SelectedObject = propertyGridControl1
propertyGridControl1.GetRowByFieldName("Size").Expanded = True
propertyGridControl1.GetRowByFieldName("Location").Expanded = True

See Also

FullExpandRow(BaseRow)

HasChildren

ExpandAllRows()

CollapseAllRows()

Collapse and Expand Rows

BaseRow Class

BaseRow Members

DevExpress.XtraVerticalGrid.Rows Namespace