Back to Devexpress

VGridOptionsBehavior.AllowCollapseRows Property

windowsforms-devexpress-dot-xtraverticalgrid-dot-vgridoptionsbehavior-00e43b01.md

latest5.5 KB
Original Source

VGridOptionsBehavior.AllowCollapseRows Property

Gets or sets whether users can click row headers or collapse buttons to collapse parent rows.

Namespace : DevExpress.XtraVerticalGrid

Assembly : DevExpress.XtraVerticalGrid.v25.2.dll

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

Declaration

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

Property Value

TypeDefaultDescription
Booleantrue

true if users can collapse parent rows; otherwise, false.

|

Property Paths

You can access this nested property as listed below:

Object TypePath to AllowCollapseRows
VGridControlBase

.OptionsBehavior .AllowCollapseRows

|

Remarks

You can group rows into categories and display rows as children of other rows. See the following topic for more information on how to create categories and nested rows: Rows.

Users can click the collapse/expand button in a category or row, double-click a category or row header, or press the plus (+) or minus (-) sign on the numeric keypad to collapse or expand a category or row.

Disable the control’s AllowCollapseRows option to prohibit users from collapsing rows. You can also use a row’s AllowCollapse property to override this setting for an individual row.

Disable the control’s ShowCollapseButtons option to hide collapse/expand buttons. You can also use a row’s ShowCollapseButton property to hide the buttons in an individual row. If users are not allowed to collapse rows, the buttons are not displayed regardless of these settings.

The code below allows users to collapse all rows except a specific row.

csharp
using DevExpress.Utils;

vGridControl1.OptionsBehavior.AllowCollapseRows = true;
rowAddress.AllowCollapse = DefaultBoolean.False;

vGridControl1.OptionsView.ShowCollapseButtons = true;
rowAddress.ShowCollapseButton = DefaultBoolean.False;
vb
Imports DevExpress.Utils

vGridControl1.OptionsBehavior.AllowCollapseRows = True
rowAddress.AllowCollapse = DefaultBoolean.False

vGridControl1.OptionsView.ShowCollapseButtons = True
rowAddress.ShowCollapseButton = DefaultBoolean.False

The control raises the RowCollapsing, RowCollapsed, RowExpanding, and RowExpanded events before and after the corresponding operation. Use the Row event argument to determine the processed row. You can set the Cancel argument to true to discard an operation before it is completed.

The handler below prohibits users from collapsing a row if a specific record is focused.

csharp
private void vGridControl1_RowCollapsing(object sender, DevExpress.XtraVerticalGrid.Events.RowCollapsingEventArgs e) {
    VGridControl gridControl = sender as VGridControl;
    if (e.Row == rowAddress && gridControl.FocusedRecord == 0)
        e.Cancel = true;
}
vb
Private Sub vGridControl1_RowCollapsing(ByVal sender As Object, ByVal e As Events.RowCollapsingEventArgs)
    Dim gridControl As VGridControl = TryCast(sender, VGridControl)
    If e.Row Is rowAddress AndAlso gridControl.FocusedRecord = 0 Then e.Cancel = True
End Sub

See Also

Collapse and Expand Rows

VGridOptionsBehavior Class

VGridOptionsBehavior Members

DevExpress.XtraVerticalGrid Namespace