Back to Devexpress

DockManager.RestoreLayoutError Event

windowsforms-devexpress-dot-xtrabars-dot-docking-dot-dockmanager-34b2095b.md

latest3.5 KB
Original Source

DockManager.RestoreLayoutError Event

Occurs when a saved layout is invalid and cannot be restored. Allows you to fix restore layout exceptions.

Namespace : DevExpress.XtraBars.Docking

Assembly : DevExpress.XtraBars.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DXCategory("Layout")]
public event EventHandler<RestoreLayoutErrorEventArgs> RestoreLayoutError
vb
<DXCategory("Layout")>
Public Event RestoreLayoutError As EventHandler(Of RestoreLayoutErrorEventArgs)

Event Data

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

PropertyDescription
ExceptionsGets the list of exceptions that occurred during the restore layout operation.
IsLayoutBrokenGets whether the layout cannot be restored due to the invalid layout file.
ThrowGets or sets whether to throw exceptions that occur during the restore layout operation.

The event data class exposes the following methods:

MethodDescription
ThrowIfRestoreLayoutExceptionsNotHandled()For internal use.

Remarks

The TabContainerActiveChildNotSetException occurs when the DockPanel.ActiveChild property of the restored tab container is not specified.

Follow the steps below to fix this exception:

  1. Handle the RestoreLayoutError event.
  2. Obtain the exception from the e.Exceptions list.
  3. Assign the container’s child panel to the ActiveChild property.
  4. Set the e.Throw property to false to suppress the exception.
csharp
void dockManager1_RestoreLayoutError(object sender, DevExpress.Utils.Serializing.RestoreLayoutErrorEventArgs e) {
    foreach (var exception in e.Exceptions) {
        if (exception is TabContainerActiveChildNotSetException activeChildException)
            activeChildException.Panel.ActiveChild = activeChildException.Panels[1];
    }
    e.Throw = false;
}

See Also

DockManager Class

DockManager Members

DevExpress.XtraBars.Docking Namespace