다음을 통해 공유


Control.TabIndex 속성

컨트롤 컨테이너 내의 컨트롤 탭 순서를 가져오거나 설정합니다.

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
<LocalizableAttribute(True)> _
Public Property TabIndex As Integer
‘사용 방법
Dim instance As Control
Dim value As Integer

value = instance.TabIndex

instance.TabIndex = value
[LocalizableAttribute(true)] 
public int TabIndex { get; set; }
[LocalizableAttribute(true)] 
public:
property int TabIndex {
    int get ();
    void set (int value);
}
/** @property */
public int get_TabIndex ()

/** @property */
public void set_TabIndex (int value)
public function get TabIndex () : int

public function set TabIndex (value : int)

속성 값

해당 컨테이너 내의 컨트롤 집합에 있는 컨트롤의 인덱스 값입니다. 컨테이너의 컨트롤은 탭 순서에 포함됩니다.

설명

탭 인덱스는 0보다 크거나 같은 모든 유효 정수로 구성될 수 있으며, 숫자가 낮을수록 탭 순서에서 앞에 있습니다. 같은 부모 컨트롤에 있는 여러 개의 컨트롤이 같은 탭 인덱스를 가질 경우 해당 컨트롤의 Z 순서가 컨트롤을 순환하는 순서를 결정합니다.

탭 순서에 포함될 컨트롤의 TabStop 속성은 true로 설정되어야 합니다.

예제

다음 코드 예제에서는 Button을 폼에 추가하고 해당 공용 속성 중 일부를 설정합니다. 예제에서는 폼의 오른쪽 아래 모퉁이에 단추를 고정시켜 폼의 크기가 조정될 경우 상대적인 위치를 유지할 수 있도록 합니다. 다음에는 BackgroundImage를 설정하고 Image와 같은 크기로 단추의 크기를 조정합니다. 그런 다음 TabStoptrue로 설정하고 TabIndex 속성을 설정합니다. 마지막으로 단추의 Click 이벤트를 처리하는 이벤트 처리기를 추가합니다. 이 예제를 실행하려면 imageList1이라는 ImageList가 있어야 합니다.

' Add a button to a form and set some of its common properties.
Private Sub AddMyButton()
   ' Create a button and add it to the form.
   Dim button1 As New Button()
   
   ' Anchor the button to the bottom right corner of the form
   button1.Anchor = AnchorStyles.Bottom Or AnchorStyles.Right
   
   ' Assign a background image.
   button1.BackgroundImage = imageList1.Images(0)

   ' Specify the layout style of the background image. Tile is the default.
   button1.BackgroundImageLayout = ImageLayout.Center
   
   ' Make the button the same size as the image.
   button1.Size = button1.BackgroundImage.Size
   
   ' Set the button's TabIndex and TabStop properties.
   button1.TabIndex = 1
   button1.TabStop = True

   ' Add a delegate to handle the Click event.
   AddHandler button1.Click, AddressOf Me.button1_Click
   
   ' Add the button to the form.
   Me.Controls.Add(button1)
End Sub
// Add a button to a form and set some of its common properties.
private void AddMyButton()
{
   // Create a button and add it to the form.
   Button button1 = new Button();

   // Anchor the button to the bottom right corner of the form
   button1.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right);

   // Assign a background image.
   button1.BackgroundImage = imageList1.Images[0];

   // Specify the layout style of the background image. Tile is the default.
   button1.BackgroundImageLayout = ImageLayout.Center;
   
   // Make the button the same size as the image.
   button1.Size = button1.BackgroundImage.Size;

   // Set the button's TabIndex and TabStop properties.
   button1.TabIndex = 1;
   button1.TabStop = true;

   // Add a delegate to handle the Click event.
   button1.Click += new System.EventHandler(this.button1_Click);

   // Add the button to the form.
   this.Controls.Add(button1);
}
   // Add a button to a form and set some of its common properties.
private:
   void AddMyButton()
   {
      // Create a button and add it to the form.
      Button^ button1 = gcnew Button;

      // Anchor the button to the bottom right corner of the form
      button1->Anchor = static_cast<AnchorStyles>(AnchorStyles::Bottom | AnchorStyles::Right);

      // Assign a background image.
      button1->BackgroundImage = imageList1->Images[ 0 ];

      // Specify the layout style of the background image. Tile is the default.
      button1->BackgroundImageLayout = ImageLayout::Center;

      // Make the button the same size as the image.
      button1->Size = button1->BackgroundImage->Size;

      // Set the button's TabIndex and TabStop properties.
      button1->TabIndex = 1;
      button1->TabStop = true;

      // Add a delegate to handle the Click event.
      button1->Click += gcnew System::EventHandler( this, &Form1::button1_Click );

      // Add the button to the form.
      this->Controls->Add( button1 );
   }
// Add a button to a form and set some of its common properties.
private void AddMyButton()
{
    // Create a button and add it to the form.
    Button button1 = new Button();
    // Anchor the button to the bottom right corner of the form
    button1.set_Anchor(AnchorStyles.Bottom | AnchorStyles.Right);
    // Assign a background image.
    button1.set_BackgroundImage(imageList1.get_Images().get_Item(0));
    // Specify the layout style of the background image. Tile is the 
    // default.
    button1.set_BackgroundImageLayout(ImageLayout.Center);
    // Make the button the same size as the image.
    button1.set_Size(button1.get_BackgroundImage().get_Size());
    // Set the button's TabIndex and TabStop properties.
    button1.set_TabIndex(1);
    button1.set_TabStop(true);
    // Add a delegate to handle the Click event.
    button1.add_Click(new System.EventHandler(this.button1_Click));
    // Add the button to the form.
    this.get_Controls().Add(button1);
} //AddMyButton

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0에서 지원

참고 항목

참조

Control 클래스
Control 멤버
System.Windows.Forms 네임스페이스
UpdateZOrder
TabStop