TabControl::TabPageCollection::Clear Method ()
.NET Framework (current version)
Removes all the tab pages from the collection.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
The following code example initially creates a TabControl with three TabPage. This example uses the Clear method to clear all controls in the tabControl1 controls collection at one instance. Then, the example adds tabPage2 back to the collection. Notice that the TabPages property is used to get the tabControl1 controls collection to remove (and add) 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; this->tabPage1 = gcnew TabPage( "tabPage1" ); this->tabPage2 = gcnew TabPage( "tabPage2" ); this->tabPage3 = gcnew TabPage( "tabPage3" ); // Populates the tabControl1 with three tab pages. array<TabPage^>^tabPages = {tabPage1,tabPage2,tabPage3}; this->tabControl1->TabPages->AddRange( tabPages ); // Removes all the tab pages from tabControl1. this->tabControl1->TabPages->Clear(); // Adds the tabPage1 back to tabControl1. this->tabControl1->TabPages->Add( tabPage2 ); 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: