Back to Devexpress

GridControl.DefaultView Property

windowsforms-devexpress-dot-xtragrid-dot-gridcontrol-67e03852.md

latest4.4 KB
Original Source

GridControl.DefaultView Property

Gets the currently maximized View.

Namespace : DevExpress.XtraGrid

Assembly : DevExpress.XtraGrid.v25.2.dll

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

Declaration

csharp
[Browsable(false)]
public BaseView DefaultView { get; }
vb
<Browsable(False)>
Public ReadOnly Property DefaultView As BaseView

Property Value

TypeDescription
BaseView

A BaseView descendant representing the currently maximized detail clone.

|

Remarks

The grid control enables you to maximize detail clones so that they are displayed as the main View. In this case, you can determine the currently maximized clone by reading the DefaultView property value. When no detail clone is maximized, the DefaultView property value matches the GridControl.MainView property value.

Please refer to the Master-Detail Relationships topic for details on maximizing detail clones.

Note : when the DefaultView property value changes, the GridControl.DefaultViewChanged event is raised.

Example

The example below shows how to maximize a detail View.

If the detail View does not exist, we should create it by expanding a specific master row. In our case, we obtain and work with the detail corresponding to the first master row.

After the master row is expanded, the detail View is obtained via GridView.GetDetailView.

Then the detail is maximized using the BaseView.ZoomView method. After that, the detail object and the GridControl.DefaultView property refer to the same maximized detail.

We use GridControl.DefaultView to group detail data rows by the “FUNCTION” column.

csharp
int rowHandle = 0;
    //Create the first detail by expanding a master row
    GridView gView = gridControl1.MainView as GridView;
    gView.SetMasterRowExpanded(rowHandle, true);
    //Get the first detail
    BaseView detail = gView.GetDetailView(rowHandle);
    if (detail != null) {
        detail.ZoomView();
        //Access the detail via DefaultView
        //Group by the FUNCTION column
        (gridControl1.DefaultView as GridView).Columns["FUNCTION"].GroupIndex = 0;
    }
vb
Dim rowHandle As Integer = 0
    'Create the first detail by expanding a master row
    Dim gView As GridView = CType(GridControl1.MainView, GridView)
    gView.SetMasterRowExpanded(rowHandle, True)
    'Get the first detail
    Dim detail As BaseView = gView.GetDetailView(rowHandle)
    If Not detail Is Nothing Then
        detail.ZoomView()
        'Access the detail via DefaultView
        'Group by the FUNCTION column
        CType(GridControl1.DefaultView, GridView).Columns("FUNCTION").GroupIndex = 0
    End If

See Also

DefaultViewChanged

MainView

NormalView()

ZoomView()

AllowZoomDetail

AutoZoomDetail

GridControl Class

GridControl Members

DevExpress.XtraGrid Namespace