Back to Devexpress

GridView.SetMasterRowExpanded(Int32, Boolean) Method

windowsforms-devexpress-dot-xtragrid-dot-views-dot-grid-dot-gridview-dot-setmasterrowexpanded-x28-system-dot-int32-system-dot-boolean-x29.md

latest8.1 KB
Original Source

GridView.SetMasterRowExpanded(Int32, Boolean) Method

Expands or collapses the specified master row.

Namespace : DevExpress.XtraGrid.Views.Grid

Assembly : DevExpress.XtraGrid.v25.2.dll

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

Declaration

csharp
public void SetMasterRowExpanded(
    int rowHandle,
    bool expand
)
vb
Public Sub SetMasterRowExpanded(
    rowHandle As Integer,
    expand As Boolean
)

Parameters

NameTypeDescription
rowHandleInt32

An integer value identifying the master row by its handle.

| | expand | Boolean |

true to expand the specified row; false to collapse it.

|

Remarks

If the expand parameter is set to true , the method expands the row making the default detail visible. The default detail is identified by the GridView.DefaultRelationIndex property value. Note that if the master row is already expanded, the method does nothing (it will not switch to the default detail if another detail is already visible). If you need to make a different detail visible, use the GridView.SetMasterRowExpandedEx method instead.

The GridOptionsDetail.AllowExpandEmptyDetails option controls whether empty details can be expanded. If this option is set to false and the default detail is empty, the SetMasterRowExpanded method will not expand this detail. Instead, the first non-empty detail will be expanded.

If the expand parameter is set to false , the method collapses the master row destroying all details. Note that the GridView.CollapseMasterRow method can be used for the same purpose.

Please refer to the Master-Detail Relationships topic, for additional information.

Note

Detail pattern Views do not contain data and they are never displayed within XtraGrid. So, the SetMasterRowExpanded member must not be invoked for these Views. The SetMasterRowExpanded member can only be used with Views that display real data within the Grid Control. Use the following methods to access these Views with which an end user interacts at runtime.

The following code snippets (auto-collected from DevExpress Examples) contain references to the SetMasterRowExpanded(Int32, Boolean) method.

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-grid-vertically-align-detail-views/CS/DetailsUnderEachOther/Form1.cs#L34

csharp
gridControl1.ForceInitialize();
gvMaster.SetMasterRowExpanded(0, true);
GridView gridRelations = (GridView)gvMaster.GetDetailView(0, 0);

winforms-grid-auto-expand-new-master-row/CS/Q205071/Form1.cs#L47

csharp
view.MasterRowExpanded += new CustomMasterRowEventHandler(OnGridViewMasterRowExpanded);
    view.SetMasterRowExpanded(view.GetRowHandle(((IList)view.DataSource).Count - 1), true);
}

winforms-preserve-grid-state-on-refresh/CS/RefreshHelperClass.cs#L167

csharp
int rowHandle = view.LocateByValue(0, column, list[i]);
    view.SetMasterRowExpanded(rowHandle, true);
}

winforms-grid-vertically-align-detail-views/VB/DetailsUnderEachOther/Form1.vb#L36

vb
gridControl1.ForceInitialize()
gvMaster.SetMasterRowExpanded(0, True)
Dim gridRelations As GridView = CType(gvMaster.GetDetailView(0, 0), GridView)

winforms-grid-auto-expand-new-master-row/VB/Q205071/Form1.vb#L49

vb
AddHandler view.MasterRowExpanded, New CustomMasterRowEventHandler(AddressOf OnGridViewMasterRowExpanded)
    view.SetMasterRowExpanded(view.GetRowHandle(CType(view.DataSource, IList).Count - 1), True)
End Sub

winforms-preserve-grid-state-on-refresh/VB/RefreshHelperClass.vb#L176

vb
Dim rowHandle As Integer = view.LocateByValue(0, column, list(i))
    view.SetMasterRowExpanded(rowHandle, True)
Next

See Also

CollapseMasterRow

ExpandMasterRow

GetDetailView(Int32, Int32)

GetVisibleDetailView(Int32)

IsMasterRow(Int32)

MasterRowCollapsed

MasterRowCollapsing

MasterRowExpanded

MasterRowExpanding

SetMasterRowExpandedEx(Int32, Int32, Boolean)

Master-Detail Relationships

GridView Class

GridView Members

DevExpress.XtraGrid.Views.Grid Namespace