TabControl.TabPageCollection.AddRange Method
Adds a set of tab pages to the collection.
Namespace: System.Windows.Forms
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 System.Drawing; using System.Windows.Forms; public class Form1 : Form { private TabControl tabControl1; private TabPage tabPage1; private TabPage tabPage2; private TabPage tabPage3; public Form1() { this.tabControl1 = new TabControl(); this.tabPage1 = new TabPage(); this.tabPage2 = new TabPage(); this.tabPage3 = new TabPage(); // Gets the controls collection for tabControl1. // Adds an array of tab pages to this collection. this.tabControl1.Controls.AddRange(new TabPage[] { tabPage1, tabPage2, tabPage3}); this.tabControl1.Location = new Point(25, 25); this.tabControl1.Size = new Size(250, 250); this.ClientSize = new Size(300, 300); this.Controls.Add(tabControl1); } static void Main() { Application.Run(new Form1()); } }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.