-
Notifications
You must be signed in to change notification settings - Fork 3
Using the Control
Jack Siro edited this page Oct 17, 2020
·
4 revisions
- Create a New Form i.e
Form1.cs
- Add the MdiTabCtrl to the empty/new form
- Dock the control to Fill
- Change all the properties through the designer to your taste.
- Create another Form i.e
ChildForm.cs
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.