Back to Devexpress

GridControl.Views Property

windowsforms-devexpress-dot-xtragrid-dot-gridcontrol-e5c6cbf5.md

latest5.4 KB
Original Source

GridControl.Views Property

Gets the collection of Views currently displayed by the grid control.

Namespace : DevExpress.XtraGrid

Assembly : DevExpress.XtraGrid.v25.2.dll

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

Declaration

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

Property Value

TypeDescription
GridControlViewCollection

A GridControlViewCollection object containing Views that are currently displayed by the grid control.

|

Remarks

The Views collection always contains the View specified by the GridControl.MainView property as its first element. Detail clones are added to the collection when they become visible (when created). When a master row is collapsed, all details created for it are destroyed. Thus, the corresponding elements are removed from the collection.

When an element is added to the Views collection, the GridControl.ViewRegistered event is raised. Removing an element from the collection raises the GridControl.ViewRemoved event. Note that you cannot add or remove Views manually. The collection returned by the Views property is read-only.

Note

Pattern Views residing within the GridControl.LevelTree tree are not included into the Views collection. These Views can be accessed via the GridControl.ViewCollection collection.

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

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

XPO_how-to-prevent-xpo-from-making-any-changes-to-a-legacy-database-e849/CS/Form1.cs#L22

csharp
// process visible clone views
foreach(ColumnView view in gridControl1.Views)
    view.OptionsBehavior.Editable = false;

winforms-grid-select-detail-rows-when-selecting-master-row/CS/MasterDetailSelectionHelper.cs#L41

csharp
{
    foreach (BaseView view in _GridView.GridControl.Views)
    {

XPO_how-to-prevent-xpo-from-making-any-changes-to-a-legacy-database-e849/VB/Form1.vb#L25

vb
' process visible clone views
For Each view As ColumnView In gridControl1.Views
    view.OptionsBehavior.Editable = False

winforms-grid-select-detail-rows-when-selecting-master-row/VB/MasterDetailSelectionHelper.vb#L34

vb
If e.Action = CollectionChangeAction.Refresh Then
    For Each view As BaseView In _GridView.GridControl.Views
        If view.IsDetailView Then

See Also

LevelTree

MainView

SetMasterRowExpandedEx(Int32, Int32, Boolean)

ViewCollection

ViewRegistered

ViewRemoved

GridControl Class

GridControl Members

DevExpress.XtraGrid Namespace