TabPage.GetTabPageOfComponent(Object) TabPage.GetTabPageOfComponent(Object) TabPage.GetTabPageOfComponent(Object) TabPage.GetTabPageOfComponent(Object) Method


지정된 개체가 들어 있는 탭 페이지를 검색합니다.Retrieves the tab page that contains the specified object.

 static System::Windows::Forms::TabPage ^ GetTabPageOfComponent(System::Object ^ comp);
public static System.Windows.Forms.TabPage GetTabPageOfComponent (object comp);
static member GetTabPageOfComponent : obj -> System.Windows.Forms.TabPage
Public Shared Function GetTabPageOfComponent (comp As Object) As TabPage

매개 변수

Object Object Object Object

찾을 개체입니다.The object to look for.


지정된 개체가 들어 있는 TabPage거나 개체를 찾을 수 없는 경우 null입니다.The TabPage that contains the specified object, or null if the object cannot be found.


다음 코드 예제는 TabControl 두 개의 TabPage 하나가 포함 된 각 개체 Button 구성 요소입니다.The following code example creates a TabControl with two TabPage objects, each containing one Button component. 매개 변수 button2 에 전달 되는 GetTabPageOfComponent 를 검색 하는 메서드를 TabPage 포함 된 button2.The parameter button2 is passed to the GetTabPageOfComponent method, which retrieves the TabPage containing button2. 올바른 탭 페이지 검색 되는 확인 하려면 합니다 SelectedIndex 속성 집합을 TabPage 포함 된 button2 현재 선택된 된 탭 페이지에.To verify that the correct tab page is retrieved, the SelectedIndex property sets the TabPage containing button2 to the currently selected tab page.

using namespace System::Drawing;
using namespace System::Windows::Forms;
public ref class Form1: public System::Windows::Forms::Form
   TabControl^ tabControl1;
   TabPage^ tabPage1;
   TabPage^ tabPage2;
   Button^ button1;
   Button^ button2;
   void InitializeMyTabs()
      tabControl1 = gcnew System::Windows::Forms::TabControl;
      tabPage1 = gcnew System::Windows::Forms::TabPage;
      tabPage2 = gcnew System::Windows::Forms::TabPage;
      button1 = gcnew System::Windows::Forms::Button;
      button2 = gcnew System::Windows::Forms::Button;
      array<System::Windows::Forms::Control^>^tabControls = {tabPage1,tabPage2};
      tabControl1->Controls->AddRange( tabControls );
      tabControl1->Location = System::Drawing::Point( 40, 24 );
      tabControl1->Size = System::Drawing::Size( 216, 216 );
      tabControl1->TabIndex = 0;
      array<System::Windows::Forms::Control^>^tabPage1Controls = {button1};
      tabPage1->Controls->AddRange( tabPage1Controls );
      tabPage1->TabIndex = 0;
      array<System::Windows::Forms::Control^>^tabPage2Controls = {button2};
      tabPage2->Controls->AddRange( tabPage2Controls );
      tabPage2->TabIndex = 1;
      button1->Location = System::Drawing::Point( 64, 72 );
      button2->Location = System::Drawing::Point( 64, 72 );
      button2->Text = "button2";
      ClientSize = System::Drawing::Size( 292, 273 );
      array<System::Windows::Forms::Control^>^formControls = {tabControl1};
      Controls->AddRange( formControls );
      // Gets the index of the TabPage containing button2.
      // Selects the index of the TabPage containing button2.
      tabControl1->SelectedIndex = (TabPage::GetTabPageOfComponent( button2 ))->TabIndex;



int main()
   Application::Run( gcnew Form1 );

using System.Drawing;
using System.Windows.Forms;

public class Form1 : System.Windows.Forms.Form
    private TabControl tabControl1;
    private TabPage tabPage1;
    private TabPage tabPage2;
    private Button button1;
    private Button button2;

    private void InitializeMyTabs()
        tabControl1 = new System.Windows.Forms.TabControl();
        tabPage1 = new System.Windows.Forms.TabPage();
        tabPage2 = new System.Windows.Forms.TabPage();
        button1 = new System.Windows.Forms.Button();
        button2 = new System.Windows.Forms.Button();

        tabControl1.Controls.AddRange(new System.Windows.Forms.Control[] {
        tabControl1.Location = new System.Drawing.Point(40, 24);
        tabControl1.Size = new System.Drawing.Size(216, 216);
        tabControl1.TabIndex = 0;

        tabPage1.Controls.AddRange(new System.Windows.Forms.Control[] {button1});
        tabPage1.TabIndex = 0;
        tabPage2.Controls.AddRange(new System.Windows.Forms.Control[] {button2});
        tabPage2.TabIndex = 1;

        button1.Location = new System.Drawing.Point(64, 72);
        button2.Location = new System.Drawing.Point(64, 72);
        button2.Text = "button2";

        ClientSize = new System.Drawing.Size(292, 273);
        Controls.AddRange(new System.Windows.Forms.Control[] {tabControl1});

        // Gets the index of the TabPage containing button2.
        // Selects the index of the TabPage containing button2. 
        tabControl1.SelectedIndex = (TabPage.GetTabPageOfComponent(button2)).TabIndex;

    public Form1()

    static void Main() 
        Application.Run(new Form1());
Imports System.Drawing
Imports System.Windows.Forms

Public Class Form1
    Inherits System.Windows.Forms.Form
    Private tabControl1 As TabControl
    Private tabPage1 As TabPage
    Private tabPage2 As TabPage
    Private button1 As Button
    Private button2 As Button

    Private Sub InitializeMyTabs()
        tabControl1 = New System.Windows.Forms.TabControl()
        tabPage1 = New System.Windows.Forms.TabPage()
        tabPage2 = New System.Windows.Forms.TabPage()
        button1 = New System.Windows.Forms.Button()
        button2 = New System.Windows.Forms.Button()

        tabControl1.Controls.AddRange(New System.Windows.Forms.Control() {tabPage1, tabPage2})
        tabControl1.Location = New System.Drawing.Point(40, 24)
        tabControl1.Size = New System.Drawing.Size(216, 216)
        tabControl1.TabIndex = 0

        tabPage1.Controls.AddRange(New System.Windows.Forms.Control() {button1})
        tabPage1.TabIndex = 0
        tabPage2.Controls.AddRange(New System.Windows.Forms.Control() {button2})
        tabPage2.TabIndex = 1

        button1.Location = New System.Drawing.Point(64, 72)
        button2.Location = New System.Drawing.Point(64, 72)
        button2.Text = "button2"

        ClientSize = New System.Drawing.Size(292, 273)
        Controls.AddRange(New System.Windows.Forms.Control() {tabControl1})

        ' Gets the index of the TabPage containing button2.
        ' Selects the index of the TabPage containing button2. 
        tabControl1.SelectedIndex = TabPage.GetTabPageOfComponent(button2).TabIndex
    End Sub

    Public Sub New()
    End Sub

    Shared Sub Main()
        Application.Run(New Form1())
    End Sub
End Class

적용 대상