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

How to: Implement the tabbed interface in an MDI application

  • 2 minutes to read

This example shows how to use an XtraTabbedMdiManager component to implement the tabbed interface in an MDI application.

When the main form (MDI Parent) is being loaded, an XtraTabbedMdiManager object is bound to the form by setting the XtraTabbedMdiManager.MdiParent property. In addition, a bar is created at the top of the form, and this contains a New command. Pressing the New command creates an MDI child form, automatically displayed as a tab by the XtraTabbedMdiManager.

The result of creating two child forms is shown below:

XtraTabbedMdiManager_Ex

using System;
using System.Windows.Forms;
using DevExpress.XtraTabbedMdi;
using DevExpress.XtraBars;

namespace WindowsFormsApplication59 {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e) {
            // Create a Bar Manager that will display a bar of commands at the top of the main form.
            BarManager barManager = new BarManager();
            barManager.Form = this;
            // Create a bar with a New button.
            barManager.BeginUpdate();
            Bar bar = new Bar(barManager, "My Bar");
            bar.DockStyle = BarDockStyle.Top;
            barManager.MainMenu = bar;
            BarItem barItem = new BarButtonItem(barManager, "New");
            barItem.ItemClick += new ItemClickEventHandler(barItem_ItemClick);
            bar.ItemLinks.Add(barItem);
            barManager.EndUpdate();
            // Create an XtraTabbedMdiManager that will manage MDI child windows.
            XtraTabbedMdiManager mdiManager = new XtraTabbedMdiManager();
            mdiManager.MdiParent = this;
        }

        int ctr = 0;
        void barItem_ItemClick(object sender, ItemClickEventArgs e) {
            // Create an MDI child form.
            Form2 f = new Form2();
            f.Text = "Child Form " + (++ctr).ToString();
            f.MdiParent = this;
            f.Show();
        }
    }
}