How can multiple tabs be created in TabControl?

“In C#, you can utilize the TabControl control to create multiple tabs. Here is a simple example code demonstrating how to use the TabControl control to create multiple tabs:”

// 创建一个TabControl控件
TabControl tabControl1 = new TabControl();
tabControl1.Dock = DockStyle.Fill;

// 创建多个选项卡
TabPage tabPage1 = new TabPage("Tab 1");
TabPage tabPage2 = new TabPage("Tab 2");
TabPage tabPage3 = new TabPage("Tab 3");

// 将选项卡添加到TabControl控件中
tabControl1.TabPages.Add(tabPage1);
tabControl1.TabPages.Add(tabPage2);
tabControl1.TabPages.Add(tabPage3);

// 将TabControl控件添加到窗体中
this.Controls.Add(tabControl1);

In the example above, we first create a TabControl control, then we create three tabs and add them to the TabControl control. Finally, we add the TabControl control to the form, and we can see multiple tabs displayed on the form.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds