windowsforms-devexpress-dot-xtrabars-dot-docking2010-dot-views-dot-baseview-f9163fe2.md
Allows you to replace the default container for floating documents. Handle this event only when the BaseView.FloatingDocumentContainer property equals DocumentsHost.
Namespace : DevExpress.XtraBars.Docking2010.Views
Assembly : DevExpress.XtraBars.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
public event CustomDocumentsHostWindowEventHandler CustomDocumentsHostWindow
Public Event CustomDocumentsHostWindow As CustomDocumentsHostWindowEventHandler
The CustomDocumentsHostWindow event's data class is DevExpress.XtraBars.Docking2010.CustomDocumentsHostWindowEventArgs.
If the FloatingDocumentContainer property equals DocumentsHost, each floating document is hosted inside a container that accepts other documents. At runtime, users can dock one floating document to another.
In this setup, floating documents are managed by Document Managers inside document containers - rather than by their source Document Manager. If you need to handle events related to floating documents, create a custom container with a Document Manager that handles all required events.
Form and implements the IDocumentHostWindows interface.csharpusing DevExpress.XtraBars.Docking2010; namespace myApp { class customDocHost : Form, IDocumentsHostWindow { public bool DestroyOnRemovingChildren { get { throw new NotImplementedException(); } } public DocumentManager DocumentManager { get { throw new NotImplementedException(); } } } }vbImports DevExpress.XtraBars.Docking2010 Namespace myApp Class customDocHost Inherits Form Implements IDocumentsHostWindow Public ReadOnly Property DestroyOnRemovingChildren() As Boolean Get Throw New NotImplementedException() End Get End Property Public ReadOnly Property DocumentManager() As DocumentManager Get Throw New NotImplementedException() End Get End Property End Class End Namespace
csharpusing DevExpress.XtraBars.Docking2010; using DevExpress.XtraBars.Docking2010.Views; namespace myApp { class customDocHost : Form, IDocumentsHostWindow { DocumentManager floatDocHost; public customDocHost() { floatDocHost = new DocumentManager(); floatDocHost.ContainerControl = this; //replace the previous code line with the following if main //Document Manager uses the MdiParent property //floatDocHost.MdiParent = this; floatDocHost.View.DocumentClosing += View_DocumentClosing; floatDocHost.View.FloatingDocumentContainer = FloatingDocumentContainer.DocumentsHost; } void View_DocumentClosing(object sender, DocumentCancelEventArgs e) { //do something } public bool DestroyOnRemovingChildren { get { return true; } } public DocumentManager DocumentManager { get { return floatDocHost; } } protected override void Dispose(bool disposing) { if (disposing) floatDocHost.Dispose(); base.Dispose(disposing); } } }vbImports DevExpress.XtraBars.Docking2010 Imports DevExpress.XtraBars.Docking2010.Views Namespace myApp Friend Class customDocHost Inherits Form Implements IDocumentsHostWindow Private floatDocHost As DocumentManager Public Sub New() floatDocHost = New DocumentManager() floatDocHost.ContainerControl = Me 'replace the previous code line with the following if main 'Document Manager uses the MdiParent property 'floatDocHost.MdiParent = Me AddHandler floatDocHost.View.DocumentClosing, AddressOf View_DocumentClosing floatDocHost.View.FloatingDocumentContainer = FloatingDocumentContainer.DocumentsHost End Sub Private Sub View_DocumentClosing(ByVal sender As Object, ByVal e As DocumentCancelEventArgs) 'do something End Sub Public ReadOnly Property DestroyOnRemovingChildren() As Boolean Get Return True End Get End Property Public ReadOnly Property DocumentManager() As DocumentManager Get Return floatDocHost End Get End Property Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then floatDocHost.Dispose() End If MyBase.Dispose(disposing) End Sub End Class End Namespace
csharpusing DevExpress.XtraBars.Docking2010; using DevExpress.XtraBars.Docking2010.Views; namespace myApp { public partial class Form1 : Form { public Form1() { InitializeComponent(); documentManager1.View.CustomDocumentsHostWindow += View_CustomDocumentsHostWindow; documentManager1.View.FloatingDocumentContainer = FloatingDocumentContainer.DocumentsHost; } void View_CustomDocumentsHostWindow(object sender, CustomDocumentsHostWindowEventArgs e) { e.Constructor = new DocumentsHostWindowConstructor(CreateCustomHost); } private customDocHost CreateCustomHost() { return new customDocHost(); } } }vbImports DevExpress.XtraBars.Docking2010 Imports DevExpress.XtraBars.Docking2010.Views Namespace myApp Partial Public Class Form1 Inherits Form Public Sub New() InitializeComponent() AddHandler documentManager1.View.CustomDocumentsHostWindow, AddressOf View_CustomDocumentsHostWindow documentManager1.View.FloatingDocumentContainer = FloatingDocumentContainer.DocumentsHost End Sub Private Sub View_CustomDocumentsHostWindow(ByVal sender As Object, ByVal e As CustomDocumentsHostWindowEventArgs) e.Constructor = New DocumentsHostWindowConstructor(AddressOf CreateCustomHost) End Sub Private Function CreateCustomHost() As customDocHost Return New customDocHost() End Function End Class End Namespace
FloatingDocumentContainer properties of these custom Document Managers are also equal to DocumentsHost (see step #2). If a user undocks a document from a custom container, this document will be placed into another default container. To fix this, ensure that instances of your class are custom containers of other custom containers.Repeat step #3 for the custom container class.
csharppublic customDocHost() { . . . floatDocHost.View.CustomDocumentsHostWindow += View_CustomDocumentsHostWindow; } void View_CustomDocumentsHostWindow(object sender, CustomDocumentsHostWindowEventArgs e) { e.Constructor = () => new customDocHost(); }vbPublic Sub customDocHost() AddHandler ...floatDocHost.View.CustomDocumentsHostWindow, AddressOf View_CustomDocumentsHostWindow End Sub Private Sub View_CustomDocumentsHostWindow(ByVal sender As Object, ByVal e As CustomDocumentsHostWindowEventArgs) e.Constructor = Function() New customDocHost() End Sub
See Also