TabControl::TabPageCollection::AddRange Method (array<TabPage^>^)
.NET Framework (current version)
Adds a set of tab pages to the collection.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
| Exception | Condition |
|---|---|
| ArgumentNullException | The value of pages equals null. |
The following code example creates a TabControl with three TabPage. This example uses the AddRange method to add an array of tab pages to the tabControl1 tab control. Notice that the TabPages property gets the tabControl1 controls collection, in order to add the array of tab pages to this collection.
Use the System.Drawing and System.Windows.Forms namespaces for this collection.
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; this->tabPage2 = gcnew TabPage; this->tabPage3 = gcnew TabPage; array<TabPage^>^tabPages = {tabPage1,tabPage2,tabPage3}; // Gets the controls collection for tabControl1. // Adds an array of tab pages to this collection. this->tabControl1->Controls->AddRange( tabPages ); 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: