C# 如何更改选项卡控件的名称

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1617251/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 19:26:01  来源:igfitidea点击:

how to change the name of the tabcontrol

c#windowswinforms

提问by Surya sasidhar

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.

我在 C# WinForms 应用程序中使用选项卡控件。我想更改选项卡的标题。默认情况下,它们是 tabPage1、tabPage2 等。

enter image description here

在此处输入图片说明

采纳答案by Quintin Robinson

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 Textproperty. Also through code via:

您可以在设计器中非常简单地更改它;点击标签页内容中的空白区域,使用属性视图设置Text属性。也通过代码通过:

tabPage1.Text = @"Something Meaningful";

Where tabPage1would be the reference to whichever TabPageyou wanted to set the Textof.

你想设置的tabPage1引用在哪里。TabPageText

回答by Andrew Keith

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

回答by Benkax

A lazy way to do it without code:

一种没有代码的懒惰方法:

  • Select the tab control
  • 选择选项卡控件

Select the tab control

选择选项卡控件

  • Go to properties, use F4to do so
  • Select TabPagesproperty, use F4to do so
  • Click the ...after the (Collection).
  • 转到属性,使用F4这样做
  • 选择TabPages属性,用于F4执行此操作
  • 单击...之后的(Collection)

tab control properties

选项卡控件属性

  • Edit the name and any tabPageproperties associated with it.
  • 编辑名称和tabPage与之关联的任何属性。

Edit the name and any <code>tabPage</code>properties

Edit the name and any <code>tabPage</code>properties