windowsforms-devexpress-dot-xtrabars-dot-docking2010.md
The component that allows you to implement tabbed, native MDI, Windows 10-inspired or Widget application UIs.
Namespace : DevExpress.XtraBars.Docking2010
Assembly : DevExpress.XtraBars.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
[DXLicenseWinForms]
[SerializationOrder(Order = 2)]
public class DocumentManager :
BaseComponent,
IUIElement,
IMdiClientSubclasserOwner,
IViewRegistrator,
IMdiClientListener,
IDocumentsHostOwner,
IAccessibleInfoProvider,
IClientControlListener,
IScaleComponentNotificationClient,
IObserver<IScaleComponentNotification>,
IBarAndDockingControllerClient,
IToolTipControlClient,
IProcessRunningListener,
IServiceProvider,
IBarMouseActivateClient,
ILogicalOwner,
ISnapSupport
<SerializationOrder(Order:=2)>
<DXLicenseWinForms>
Public Class DocumentManager
Inherits BaseComponent
Implements IUIElement,
IMdiClientSubclasserOwner,
IViewRegistrator,
IMdiClientListener,
IDocumentsHostOwner,
IAccessibleInfoProvider,
IClientControlListener,
IScaleComponentNotificationClient,
IObserver(Of IScaleComponentNotification),
IBarAndDockingControllerClient,
IToolTipControlClient,
IProcessRunningListener,
IServiceProvider,
IBarMouseActivateClient,
ILogicalOwner,
ISnapSupport
The following members return DocumentManager objects:
The DocumentManager component is a powerful tool capable of emulating most popular classic and modern application UIs, including:
Each of these UI types is implemented via the related View object (TabbedView, NativeMdiView, WindowsUIView or WidgetView), derived from the BaseView class. All of these Views share a common concept - managing Document objects. A Document is a metaphor, a non-visual object that can wrap any form, user-control, standard or third-party control (see the Documents topic to learn how to create and manage Documents). Each View operates its own Document type, derived from the base BaseDocument class, and stores its Documents in the BaseView.Documents collection. To assign a required View to the DocumentManager, use the DocumentManager.View property.
The DocumentManager component can be used with the Dock Manager within the single application form. In this case, both of these DevExpress components gain several unique features, listed in the Interaction with Dock Panels topic. If you want these features for your application, but do not need multiple Documents within your View, switch the DocumentManager to the Non-Document Mode.
Note
If you need a simple and plain tabbed UI with minimum additional features, we recommend using the XtraTabbedMdiManager component rather then the DocumentManager with Tabbed View applied.
This example shows how to enable a native MDI for a DocumentManager where MDI child windows are presented as regular windows within a container.
//Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraBars.Docking2010;
using DevExpress.XtraBars.Docking2010.Views.NativeMdi;
using DevExpress.XtraEditors;
namespace DocumentManager_NativeMDI {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
int childCount = 0;
private void Form1_Load(object sender, EventArgs e) {
CreateDocumentManager();
for(int i = 0; i < 3; i++) {
AddChild();
}
}
void CreateDocumentManager() {
DocumentManager dm = new DocumentManager(components);
dm.MdiParent = this;
dm.View = new NativeMdiView();
}
void AddChild() {
Form childForm = null;
childForm = new Form();
childForm.Text = "Child Form " + (++childCount);
SimpleButton btn = new SimpleButton();
btn.Text = "Button " + childCount;
btn.Parent = childForm;
childForm.MdiParent = this;
childForm.Show();
}
}
}
'Form1.vb
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports DevExpress.XtraBars.Docking2010
Imports DevExpress.XtraBars.Docking2010.Views.NativeMdi
Imports DevExpress.XtraEditors
Namespace DocumentManager_NativeMDI
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private childCount As Integer = 0
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
CreateDocumentManager()
For i As Integer = 0 To 2
AddChild()
Next i
End Sub
Private Sub CreateDocumentManager()
Dim dm As New DocumentManager(components)
dm.MdiParent = Me
dm.View = New NativeMdiView()
End Sub
Private Sub AddChild()
Dim childForm As Form = Nothing
childForm = New Form()
childCount += 1
childForm.Text = "Child Form " & (childCount)
Dim btn As New SimpleButton()
btn.Text = "Button " & childCount
btn.Parent = childForm
childForm.MdiParent = Me
childForm.Show()
End Sub
End Class
End Namespace
This example enables a tabbed UI for a DocumentManager. The example creates two document groups. MDI child windows are presented as tab pages.
using DevExpress.XtraEditors;
using DevExpress.XtraBars.Docking2010;
using DevExpress.XtraBars.Docking2010.Views.Tabbed;
using System.Windows.Forms;
namespace DXApplication {
public partial class Form1 : XtraForm {
DocumentManager docManager;
public Form1() {
InitializeComponent();
InitDocumentManager();
AddChildForms(5);
AddDocumentGroup(Orientation.Vertical, 2);
}
void InitDocumentManager() {
docManager = new DocumentManager(components) {
MdiParent = this,
View = new TabbedView()
};
}
void AddChildForms(int count) {
for (int i = 0; i < count; i++)
AddChildForm(i);
}
void AddDocumentGroup(Orientation groupOrientation, int documentIndex) {
(docManager.View as TabbedView).Controller.CreateNewDocumentGroup(docManager.View.Documents[documentIndex] as Document, groupOrientation);
}
void AddChildForm(int number) {
XtraForm childForm = new XtraForm() {
Text = string.Format("Child Form ({0})", number),
MdiParent = this
};
SimpleButton btn = new SimpleButton() {
Text = string.Format("Button"),
Parent = childForm
};
childForm.Show();
}
}
}
Imports DevExpress.XtraEditors
Imports DevExpress.XtraBars.Docking2010
Imports DevExpress.XtraBars.Docking2010.Views.Tabbed
Imports System.Windows.Forms
Namespace DXApplication
Partial Public Class Form1
Inherits XtraForm
Private docManager As DocumentManager
Public Sub New()
InitializeComponent()
InitDocumentManager()
AddChildForms(5)
AddDocumentGroup(Orientation.Vertical, 2)
End Sub
Private Sub InitDocumentManager()
docManager = New DocumentManager(components) With {
.MdiParent = Me,
.View = New TabbedView()
}
End Sub
Private Sub AddChildForms(ByVal count As Integer)
For i As Integer = 0 To count - 1
AddChildForm(i)
Next i
End Sub
Private Sub AddDocumentGroup(ByVal groupOrientation As Orientation, ByVal documentIndex As Integer)
TryCast(docManager.View, TabbedView).Controller.CreateNewDocumentGroup(TryCast(docManager.View.Documents(documentIndex), Document), groupOrientation)
End Sub
Private Sub AddChildForm(ByVal number As Integer)
Dim childForm As New XtraForm() With {
.Text = String.Format("Child Form ({0})", number),
.MdiParent = Me
}
Dim btn As New SimpleButton() With {
.Text = String.Format("Button"),
.Parent = childForm
}
childForm.Show()
End Sub
End Class
End Namespace
This example demonstrates how to create and customize the WidgetView at runtime. In this example, the WidgetView contains two StackGroups, which host three Documents. Each Document displays different content in its normal and maximized states. StackGroups have relative lengths (their Length.UnitType properties are set to Star ), which allows them to dynamically resize whenever the parent form resizes.
Note
1. When creating the Widget View-based application at runtime, do not specify the DocumentManager.MdiParent property manually. Otherwise, widgets will not be displayed.
2. Be sure to set the DocumentManager.ContainerControl property after the View is created and assigned to the DocumentManager.View property.
//ucPreview.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WidgetViewExample {
public partial class ucPreview : UserControl {
public ucPreview() {
InitializeComponent();
}
}
}
//ucMaximizedContent.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WidgetViewExample {
public partial class ucMaximizedContent : UserControl {
public ucMaximizedContent() {
InitializeComponent();
}
}
}
//Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraBars.Docking2010;
using DevExpress.XtraBars.Docking2010.Views.Widget;
using DevExpress.XtraEditors;
namespace WidgetViewExample {
public partial class Form1 : XtraForm {
public Form1() {
InitializeComponent();
}
void Form1_Load(object sender, EventArgs e) {
AddDocumentManager();
for (int i = 0; i < 3; i++) {
AddDocuments();
}
//Adding Documents to group1 is not necessary, since all newly created Documents are automatically placed in the first StackGroup.
group1.Items.AddRange(new Document[] { view.Documents[0] as Document, view.Documents[1] as Document });
view.Controller.Dock(view.Documents[2] as Document, group2);
}
WidgetView view;
StackGroup group1, group2;
void AddDocumentManager() {
DocumentManager dM = new DocumentManager(components);
view = new WidgetView();
dM.View = view;
view.AllowDocumentStateChangeAnimation = DevExpress.Utils.DefaultBoolean.True;
group1 = new StackGroup();
group2 = new StackGroup();
group1.Length.UnitType = LengthUnitType.Star;
group1.Length.UnitValue = 2;
view.StackGroups.AddRange(new StackGroup[] { group1, group2 });
dM.ContainerControl = this;
}
int count = 1;
void AddDocuments() {
Document document = view.AddDocument(new ucPreview()) as Document;
document.MaximizedControl = new ucMaximizedContent();
count++;
}
}
}
'ucPreview.vb
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Drawing
Imports System.Data
Imports System.Linq
Imports System.Text
Imports System.Threading.Tasks
Imports System.Windows.Forms
Namespace WidgetViewExample
Partial Public Class ucPreview
Inherits UserControl
Public Sub New()
InitializeComponent()
End Sub
End Class
End Namespace
'ucMaximizedContent.vb
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Drawing
Imports System.Data
Imports System.Linq
Imports System.Text
Imports System.Threading.Tasks
Imports System.Windows.Forms
Namespace WidgetViewExample
Partial Public Class ucMaximizedContent
Inherits UserControl
Public Sub New()
InitializeComponent()
End Sub
End Class
End Namespace
'Form1.vb
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Threading.Tasks
Imports System.Windows.Forms
Imports DevExpress.XtraBars.Docking2010
Imports DevExpress.XtraBars.Docking2010.Views.Widget
Imports DevExpress.XtraEditors
Namespace WidgetViewExample
Partial Public Class Form1
Inherits XtraForm
Public Sub New()
InitializeComponent()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
AddDocumentManager()
For i As Integer = 0 To 2
AddDocuments()
Next i
'Adding Documents to group1 is not necessary, since all newly created Documents are automatically placed in the first StackGroup.
group1.Items.AddRange(New Document() { TryCast(view.Documents(0), Document), TryCast(view.Documents(1), Document) })
view.Controller.Dock(TryCast(view.Documents(2), Document), group2)
End Sub
Private view As WidgetView
Private group1, group2 As StackGroup
Private Sub AddDocumentManager()
Dim dM As New DocumentManager(components)
view = New WidgetView()
dM.View = view
view.AllowDocumentStateChangeAnimation = DevExpress.Utils.DefaultBoolean.True
group1 = New StackGroup()
group2 = New StackGroup()
group1.Length.UnitType = LengthUnitType.Star
group1.Length.UnitValue = 2
view.StackGroups.AddRange(New StackGroup() { group1, group2 })
dM.ContainerControl = Me
End Sub
Private count As Integer = 1
Private Sub AddDocuments()
Dim document As Document = TryCast(view.AddDocument(New ucPreview()), Document)
document.MaximizedControl = New ucMaximizedContent()
count += 1
End Sub
End Class
End Namespace
The Document Manager allows you to select the container type for documents (DocumentManager.View.FloatingDocumentContainer):
FloatingDocumentContainer property is set to SingleDocument, a floating document is hosted within its individual container.FloatingDocumentContainer property is set to DocumentsHost, floating documents are hosted within a container to which other documents can be docked. Documents docked to a floating container are displayed as tabs.The example uses this feature to create a web browser UI.
Object MarshalByRefObject Component BaseComponent DocumentManager XRTabbedMdiManager
See Also