expressappframework-113443-ui-construction-templates-in-winforms-how-to-access-the-document-manager.md
This topic demonstrates how to access the Document Manager that the MdiShowViewStrategy uses to show Views in a WinForms application. You will locate tab captions to the left and orient them horizontally.
Here, it is assumed that you have the UI type set to TabbedMDI in the Model Editor for your Windows Forms application (see IModelOptionsWin.UIType). Perform the following steps to access the DocumentManager object and customize its default settings.
using DevExpress.ExpressApp;
using DevExpress.XtraBars.Docking2010;
using DevExpress.XtraBars.Docking2010.Views;
using DevExpress.XtraBars.Docking2010.Views.Tabbed;
using DevExpress.ExpressApp.Templates;
// ...
public class TabsCustomizationWindowController : WindowController {
public TabsCustomizationWindowController() {
TargetWindowType = WindowType.Main;
}
protected override void OnActivated() {
base.OnActivated();
Window.TemplateChanged += Window_TemplateChanged;
}
private void Window_TemplateChanged(object sender, EventArgs e) {
IFrameTemplate template = Window.Template;
DocumentManager docManager = ((IDocumentsHostWindow)template).DocumentManager;
docManager.ViewChanged += docManager_ViewChanged;
CustomizeDocumentManagerView(docManager.View);
}
private void docManager_ViewChanged(object sender, ViewEventArgs args) {
CustomizeDocumentManagerView(args.View);
}
private static void CustomizeDocumentManagerView(BaseView view) {
if(view is TabbedView) {
((TabbedView)view).DocumentGroupProperties.HeaderLocation =
DevExpress.XtraTab.TabHeaderLocation.Left;
((TabbedView)view).DocumentGroupProperties.HeaderOrientation =
DevExpress.XtraTab.TabOrientation.Horizontal;
}
}
protected override void OnDeactivated() {
Window.TemplateChanged -= Window_TemplateChanged;
base.OnDeactivated();
}
}
Run the application to ensure that the tab captions location is changed.