Back to Devexpress

BaseView.EmptyDocumentsHostWindow Event

windowsforms-devexpress-dot-xtrabars-dot-docking2010-dot-views-dot-baseview-d5e5d5c0.md

latest5.1 KB
Original Source

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.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
public event EmptyDocumentsHostWindowEventHandler EmptyDocumentsHostWindow
vb
Public Event EmptyDocumentsHostWindow As EmptyDocumentsHostWindowEventHandler

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 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.

csharp
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.
}
vb
Private Sub TabbedView1_RegisterDocumentsHostWindow(sender As Object, e As DevExpress.XtraBars.Docking2010.DocumentsHostWindowEventArgs) Handles TabbedView1.RegisterDocumentsHostWindow
    AddHandler e.HostWindow.DocumentManager.View.EmptyDocumentsHostWindow, AddressOf View_EmptyDocumentsHostWindow
End Sub
Private Sub TabbedView1_UnregisterDocumentsHostWindow(sender As Object, e As DevExpress.XtraBars.Docking2010.DocumentsHostWindowEventArgs) Handles TabbedView1.UnregisterDocumentsHostWindow
    RemoveHandler e.HostWindow.DocumentManager.View.EmptyDocumentsHostWindow, AddressOf View_EmptyDocumentsHostWindow
End Sub
Private Sub View_EmptyDocumentsHostWindow(sender As Object, e As DevExpress.XtraBars.Docking2010.EmptyDocumentsHostWindowEventArgs)
    ' set the e.KeepOpen property based on custom logic.
End Sub

See Also

CustomDocumentsHostWindow

RegisterDocumentsHostWindow

BaseView Class

BaseView Members

DevExpress.XtraBars.Docking2010.Views Namespace