简体   繁体   中英

how to change the name of the tabcontrol

I am using a Tab Control in a C# WinForms application. I want to change the title of the tabs. By default they are tabPage1, tabPage2, etc.

在此处输入图像描述

A lazy way to do it without code:

  • Select the tab control

选择选项卡控件

  • Go to properties, use F4 to do so
  • Select TabPages property, use F4 to do so
  • Click the ... after the (Collection) .

选项卡控件属性

  • Edit the name and any tabPage properties associated with it.

编辑名称和任何 <code>tabPage</code> 属性

You can change it pretty simply in the designer; click on a blank area in the tab page contents and use the property view to set the Text property. Also through code via:

tabPage1.Text = @"Something Meaningful";

Where tabPage1 would be the reference to whichever TabPage you wanted to set the Text of.

tabCtrl.TabPages[0].Text = "some text";
tabCtrl.TabPages[1].Text = "some other text";

Going into the designer.cs you can change the tab Text like so this.tabPage3.Text = 'Your Title'

Method

//Component Designer generated code
 private void InitializeComponent()
 {      
  ...
  this.tabControl1 = new System.Windows.Forms.TabControl();
  ...
  // 
  // tabPage3
  // 
   this.tabPage3.Location = new System.Drawing.Point(4, 22);
   this.tabPage3.Name = "tabPage3";
   ...        
   this.tabPage3.Text = "tabPage3";//change the tab name
   ...
  }

It will auto refresh the Design view.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM