Back to Devexpress

BaseView.BeforeLoadLayout Event

windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-dot-baseview-a512a577.md

latest4.1 KB
Original Source

BaseView.BeforeLoadLayout Event

Occurs before a layout is restored from storage (a stream, xml file or the system registry).

Namespace : DevExpress.XtraGrid.Views.Base

Assembly : DevExpress.XtraGrid.v25.2.dll

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

Declaration

csharp
[DXCategory("Data")]
public event LayoutAllowEventHandler BeforeLoadLayout
vb
<DXCategory("Data")>
Public Event BeforeLoadLayout As LayoutAllowEventHandler

Event Data

The BeforeLoadLayout event's data class is LayoutAllowEventArgs. The following properties provide information specific to this event:

PropertyDescription
AllowGets or sets whether to allow upgrading the control layout.
NewHiddenItemsReturns an array of items that exist in the current control but do not exist in the layout being loaded. These items are hidden. This property is in effect for the LayoutControl. Inherited from LayoutUpgradeEventArgs.
PreviousVersionReturns the textual representation of the previous layout version. Inherited from LayoutUpgradeEventArgs.

Remarks

The BeforeLoadLayout event allows you to prevent the layout from being restored from storage and thus being applied to the current View.

This event is fired when an attempt is made to restore a layout from storage using one of the following methods: BaseView.RestoreLayoutFromRegistry, BaseView.RestoreLayoutFromStream and BaseView.RestoreLayoutFromXml. To stop the layout from being restored from the storage set the event’s Allow parameter to false.

The event’s PreviousVersion parameter defines the version of the layout being restored. This can be compared with the version of the current layout specified by the OptionsLayoutBase.LayoutVersion property of the BaseView.OptionsLayout object. The restoring of the layout can be cancelled, for instance if the versions do not match.

csharp
gridView1.BeforeLoadLayout += (s, ea) => {
    GridView view = s as GridView;
    if (ea.PreviousVersion != view.OptionsLayout.LayoutVersion)
        ea.Allow = false;
};
vb
AddHandler GridView1.BeforeLoadLayout, Sub(s, ea)
    Dim view As GridView = TryCast(s, GridView)
    If ea.PreviousVersion <> view.OptionsLayout.LayoutVersion Then ea.Allow = False
End Sub

See Also

LayoutUpgrade

OptionsLayout

Save and Restore Layouts of DevExpress controls

BaseView Class

BaseView Members

DevExpress.XtraGrid.Views.Base Namespace