TabControl::TabPageCollection::RemoveAt Method (Int32)
.NET Framework (current version)
Removes the tab page at the specified index from the collection.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Parameters
- index
-
Type:
System::Int32
The zero-based index of the TabPage to remove.
Implements
IList::RemoveAt(Int32)The following code example initially creates a TabControl with three TabPage. This example uses the RemoveAt method to remove tabPage1, which is specified by its index, from the tabControl1 controls collection. Notice that the TabPages property gets the tabControl1 controls collection to add and remove tab pages from this collection.
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; TabPage^ tabPage2; TabPage^ tabPage3; public: Form1() { this->tabControl1 = gcnew TabControl; array<System::String^>^tabText = {"tabPage1","tabPage2","tabPage3"}; this->tabPage1 = gcnew TabPage( tabText[ 0 ]->ToString() ); this->tabPage2 = gcnew TabPage( tabText[ 1 ]->ToString() ); this->tabPage3 = gcnew TabPage( tabText[ 2 ]->ToString() ); // Populates the tabControl1 with three tab pages. array<TabPage^>^tabPages = {tabPage1,tabPage2,tabPage3}; this->tabControl1->TabPages->AddRange( tabPages ); // Assigns TabIndex values to tab pages. this->tabPage1->TabIndex = 0; this->tabPage2->TabIndex = 1; this->tabPage3->TabIndex = 2; // Gets the tabControl1 controls collection. // Removes the tabPage1 by its TabIndex. this->tabControl1->TabPages->RemoveAt( 0 ); this->tabControl1->Location = Point(25,25); this->tabControl1->Size = System::Drawing::Size( 250, 250 ); this->ClientSize = System::Drawing::Size( 300, 300 ); this->Controls->Add( tabControl1 ); } }; int main() { Application::Run( gcnew Form1 ); }
.NET Framework
Available since 1.1
Available since 1.1
Show: