Ribbon for WinForms
MDI 子 RibbonForm
リボンの使用 > MDI 子 RibbonForm

The Ribbon control supports MDI (Multiple document Interface) Child Ribbon Forms, which is quite useful in user interaction. This section illustrates how to create MDI Child forms using the Ribbon control.

The RibbonForm can be used in MDI scenarios. The MDI feature lets you share a single menu bar between all child windows, increasing the efficiency of screen space usage. 

Creating MDI form

In order to create an MDI parent RibbonForm and child form, follow the steps below:

  1. Create a RibbonForm.
    C#
    コードのコピー
    partial class Form1 : C1RibbonForm
    {
        //...
    }
    
  2. Set up the MDI parent form by setting Form.IsMdIContainer property to true, and make the window maximized.

    C#
    コードのコピー
    public ParentForm()
    {
        InitializeComponent();
        this.Text = "Parent Form";
        this.IsMdiContainer = true;
        this.WindowState = FormWindowState.Maximized;
    }
    
  3. Add tool strip menu items, 'New' and ‘Open’ buttons to the menu strip in the RibbonForm, such that on clicking each button a child form opens, NewForm and OpenForm (which, we will create in the next step).

  4. Add the following code to create and display the MDI child form 'NewForm' and assign border size to the MDI Child Form using the MdiChildBorder property in the ToolStripMenuItem_Click event for the New button.

    C#
    コードのコピー
    private void newToolStripMenuItem_Click(object sender, EventArgs e)
    {
        NewForm cfrm1 = new NewForm();
        //子C1RibbonFormのMdiChildBorderプロパティを設定します
        cfrm1.MdiChildBorder = 2; 
        cfrm1.MdiParent = this;
        cfrm1.StartPosition = FormStartPosition.CenterScreen;
        cfrm1.Show();
    }
    
  5. Add the following code to create and display the MDI child form 'OpenForm' using the ToolStripMenuItem_Click event for the Open button.

    C#
    コードのコピー
    private void openToolStripMenuItem_Click(object sender, EventArgs e)
    {
        OpenForm cfrm2 = new OpenForm();
        cfrm2.Show();
        cfrm2.MdiParent = this;
    }