A newer version of this page is available. Switch to the current version.

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


public BaseView MainView { get; set; }
Public Property MainView As BaseView

Property Value

Type Default Description


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


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.


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.

See Also