TabPage::Text Property
.NET Framework (current version)
Gets or sets the text to display on the tab.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
public: [BrowsableAttribute(true)] property String^ Text { virtual String^ get() override; virtual void set(String^ value) override; }
Changing the Text property value does not automatically center the new value on the tab if the TabControl has a SizeMode property value of Fixed. You can work around this limitation by setting the TabControl::ItemSize property or by removing the TabPage from the TabControl::TabPages collection and adding it back to the collection. Both of these actions will automatically center the text.
The following code example creates a TabControl with one TabPage. The Text property sets the tab page text to myTabPage.
Use the System.Drawing and System.Windows.Forms namespaces for this example.
using namespace System::Drawing; using namespace System::Windows::Forms; public ref class Form1: public Form { private: TabControl^ tabControl1; TabPage^ tabPage1; void MyTabs() { this->tabControl1 = gcnew TabControl; this->tabPage1 = gcnew TabPage; array<Control^>^tabControl1Controls = {this->tabPage1}; this->tabControl1->Controls->AddRange( tabControl1Controls ); this->tabControl1->Location = Point(25,25); this->tabControl1->Size = System::Drawing::Size( 250, 250 ); // Displays a string, myTabPage, on tabPage1. this->tabPage1->Text = "myTabPage"; this->ClientSize = System::Drawing::Size( 300, 300 ); array<Control^>^formControls = {this->tabControl1}; this->Controls->AddRange( formControls ); } public: Form1() { MyTabs(); } }; int main() { Application::Run( gcnew Form1 ); }
.NET Framework
Available since 1.1
Available since 1.1
Show: