Skip to main content
A newer version of this page is available. .

DocumentManager Class

The component that allows you to implement tabbed, native MDI, Windows 10-inspired or Widget application UIs.

Namespace: DevExpress.XtraBars.Docking2010

Assembly: DevExpress.XtraBars.v21.2.dll

NuGet Packages: DevExpress.Win.Design, DevExpress.Win.Navigation

Declaration

[SerializationOrder(Order = 2)]
public class DocumentManager :
    BaseComponent,
    IUIElement,
    IMdiClientSubclasserOwner,
    IViewRegistrator,
    IMdiClientListener,
    IDocumentsHostOwner,
    IAccessibleInfoProvider,
    IClientControlListener,
    IScaleComponentNotificationClient,
    IObserver<IScaleComponentNotification>,
    IBarAndDockingControllerClient,
    IToolTipControlClient,
    IProcessRunningListener,
    IServiceProvider,
    IBarMouseActivateClient,
    ILogicalOwner,
    ISnapSupport

Remarks

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.

Native MDI View Example

This example shows how to enable a native MDI for a DocumentManager where MDI child windows are presented as regular windows within a container.

NativeMdi_ex

View Example

//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();
        }
    }
}

Tabbed View Example

This example shows how to enable a tabbed UI for a DocumentManager where MDI child windows are presented as tab pages.

TabbedUI_ex

View Example

//Form1.cs
using System;
using System.Windows.Forms;
using DevExpress.XtraBars.Docking2010;
using DevExpress.XtraBars.Docking2010.Views.Tabbed;
using DevExpress.XtraEditors;

namespace DocumentManager_TabbedUI {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }
        void Form1_Load(object sender, EventArgs e) {
            AddDocumentManager();
            for(int i = 0; i < 3; i++) {
                AddChildForm();
            }
        }
        void AddDocumentManager() {
            DocumentManager manager = new DocumentManager(components);
            manager.MdiParent = this;
            manager.View = new TabbedView();
        }
        int count;
        void AddChildForm() {
            Form childForm = new Form();
            childForm.Text = "Child Form " + (++count).ToString();

            SimpleButton btn = new SimpleButton();
            btn.Text = "Button " + count.ToString();
            btn.Parent = childForm;

            childForm.MdiParent = this;
            childForm.Show();
        }
    }
}

Widget View Example

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.

View Example

//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++;
        }
    }
}

Windows UI View Getting Started

Getting Started

See Also