TabControl::TabPageCollection::IndexOf Method (TabPage^)
.NET Framework (current version)
Returns the index of the specified tab page in the collection.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Parameters
- page
-
Type:
System.Windows.Forms::TabPage^
The TabPage to locate in the collection.
| Exception | Condition |
|---|---|
| ArgumentNullException | The value of page is null. |
The following code example creates a TabControl with one TabPage. This example uses the IndexOf method to retrieve the tabPage1 index value. A ToolTip is used to display this value.
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; public: Form1() { this->tabControl1 = gcnew TabControl; this->tabPage1 = gcnew TabPage( "myTabPage" ); this->tabControl1->TabPages->Add( tabPage1 ); this->tabControl1->ShowToolTips = true; this->tabControl1->Location = Point(25,25); this->tabControl1->Size = System::Drawing::Size( 250, 250 ); this->tabPage1->ToolTipText = System::String::Concat( "TabIndex = ", (tabControl1->TabPages->IndexOf( tabPage1 )).ToString() ); // Gets the tabPage1 TabIndex value from the tabControl1 controls collection. // Converts the tabPage1 TabIndex value to a string. 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: