BaseView.EmptyDocumentsHostWindow Event
Fires when the last floating document in the documents host window is closed or the control it contains is disposed, allowing you to specify whether to keep open the empty documents host window.
Namespace: DevExpress.XtraBars.Docking2010.Views
Assembly: DevExpress.XtraBars.v24.1.dll
NuGet Package: DevExpress.Win.Navigation
Declaration
Event Data
The EmptyDocumentsHostWindow event's data class is DevExpress.XtraBars.Docking2010.EmptyDocumentsHostWindowEventArgs.
Remarks
This event is in effect for views that display floating documents in the documents host window in which multiple documents can be docked as tabs. See the BaseView.FloatingDocumentContainer property for details.
For the view in the documents host window, the EmptyDocumentsHostWindow event fires when:
- the last document (BaseDocument) in the BaseView.Documents collection is closed;
- the control displayed in the last document (BaseDocument.Control) is disposed.
The Reason property of the EmptyDocumentsHostWindowEventArgs object, passed to the event handler, returns whether the document has been closed or the control has been disposed.
The HostWindow property returns the IDocumentsHostWindow object that contains the document.
The KeepOpen property allows you to specify whether not to close the host window. If the document is contained in the default documents host window, this property is set to false by default. So, the default host window is automatically closed. If a custom host window is used to contain floating documents (see BaseView.CustomDocumentsHostWindow), the KeepOpen property is set to true, by default.
To subscribe to the EmptyDocumentsHostWindow event of the view in the documents host window, use the BaseView.RegisterDocumentsHostWindow event of the main view. See the example below.
public Form1()
{
InitializeComponent();
tabbedView1.RegisterDocumentsHostWindow += tabbedView1_RegisterDocumentsHostWindow;
tabbedView1.UnregisterDocumentsHostWindow += tabbedView1_UnregisterDocumentsHostWindow;
}
void tabbedView1_RegisterDocumentsHostWindow(object sender, DevExpress.XtraBars.Docking2010.DocumentsHostWindowEventArgs e)
{
e.HostWindow.DocumentManager.View.EmptyDocumentsHostWindow += View_EmptyDocumentsHostWindow;
}
void tabbedView1_UnregisterDocumentsHostWindow(object sender, DevExpress.XtraBars.Docking2010.DocumentsHostWindowEventArgs e)
{
e.HostWindow.DocumentManager.View.EmptyDocumentsHostWindow -= View_EmptyDocumentsHostWindow;
}
void View_EmptyDocumentsHostWindow(object sender, DevExpress.XtraBars.Docking2010.EmptyDocumentsHostWindowEventArgs e)
{
// set the e.KeepOpen property based on custom logic.
}