Skip to content

Using the Control

Jack Siro edited this page Oct 17, 2020 · 4 revisions

To use the control

  1. Create a New Form i.e Form1.cs
  2. Add the MdiTabCtrl to the empty/new form
  3. Dock the control to Fill
  4. Change all the properties through the designer to your taste.
  5. Create another Form i.e ChildForm.cs

To insert a TabPage (Form) in the control:

using System.Windows.Forms;

namespace MdiTabCtrlSample
{
    public partial class Form1 : Form
    {
        private int tabcount;

        public Form1()
        {
            InitializeComponent();

            NewTab();
            NewTab();
            NewTab();
            tabControl1.TabPages[1].Select(); //select a tab page of choice
        }

        public void NewTab()
        {
            Form cform = new ChildForm(); //call an instance of a class you want to show in a tab
            tabcount = tabcount + 1;
            cform.Text = "This is Tab " + tabcount; //Declare text for this tab
            tabControl1.TabPages.Add(cform);
        }
    }
}
  • You don't show the form, instead you just add it to the control. Very simple, isn't it? On an existing program, you just need to add the control to the main form, and where you have the Show call for the form, you just replace by the Add method.
Clone this wiki locally