Skip to main content
A newer version of this page is available. .

GridControl.MainView Property

Gets or sets the View that displays data at the top hierarchy level.

Namespace: DevExpress.XtraGrid

Assembly: DevExpress.XtraGrid.v18.2.dll

Declaration

[Browsable(false)]
[DefaultValue(null)]
public BaseView MainView { get; set; }

Property Value

Type Default Description
BaseView *null*

A BaseView descendant representing the View that displays data at the top hierarchy level.

Remarks

When the grid control doesn’t display master-detail data, the View specified by the MainView property is the only View that displays data. By default, when the grid control is created, it initializes the MainView property with a GridView object with default settings. Thus, if you need to display data using a Card View, create a new CardView object and assign it to the MainView property.

When using the grid control to display master-detail relationships, the MainView property specifies the View that will represent the top level data. This is the data specified by the grid control’s GridControl.DataSource and GridControl.DataMember properties. Detail data is represented by Views stored within the GridControl.LevelTree tree or supplied by the master View’s GridView.MasterRowGetLevelDefaultView event handler.

All Views currently displayed are stored within the GridControl.Views collection. The first element in the collection is the MainView property value. Other elements are added or removed dynamically when detail clones are expanded and collapsed respectively.

Note

Do not set the MainView property while wrapping the setter with the GridControl.BeginUpdate and GridControl.EndUpdate method pair. Instead, set the MainView property outside the BeginUpdate/EndUpdate block.

The following code snippets (auto-collected from DevExpress Examples) contain references to the MainView 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.

See Also