Ribbon for WinForms | ComponentOne
Work with Ribbon / MDI Child RibbonForm
In This Topic
    MDI Child RibbonForm
    In This Topic

    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. 

    GIF showing a new form on clicking File tab

    Creating MDI form

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

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

      C#
      Copy Code
      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#
      Copy Code
      private void newToolStripMenuItem_Click(object sender, EventArgs e)
      {
          NewForm cfrm1 = new NewForm();
          //Set MdiChildBorder property for a child C1RibbonForm
          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#
      Copy Code
      private void openToolStripMenuItem_Click(object sender, EventArgs e)
      {
          OpenForm cfrm2 = new OpenForm();
          cfrm2.Show();
          cfrm2.MdiParent = this;
      }