TreeNodeCollection.Item[] 속성

정의

컬렉션 내의 트리 노드를 가져오거나 설정합니다.

오버로드

Name Description
Item[Int32]

컬렉션에서 TreeNode 지정된 인덱싱된 위치를 가져오거나 설정합니다.

Item[String]

컬렉션에서 지정된 키를 가진 트리 노드를 가져옵니다.

Item[Int32]

Source:
TreeNodeCollection.cs
Source:
TreeNodeCollection.cs
Source:
TreeNodeCollection.cs
Source:
TreeNodeCollection.cs
Source:
TreeNodeCollection.cs

컬렉션에서 TreeNode 지정된 인덱싱된 위치를 가져오거나 설정합니다.

public:
 virtual property System::Windows::Forms::TreeNode ^ default[int] { System::Windows::Forms::TreeNode ^ get(int index); void set(int index, System::Windows::Forms::TreeNode ^ value); };
public virtual System.Windows.Forms.TreeNode this[int index] { get; set; }
member this.Item(int) : System.Windows.Forms.TreeNode with get, set
Default Public Overridable Property Item(index As Integer) As TreeNode

매개 변수

index
Int32

컬렉션에서 인덱싱된 위치 TreeNode 입니다.

속성 값

TreeNode 컬렉션의 지정된 인덱싱된 위치에 있는 위치입니다.

예외

.NET 6 이상 버전: indexnull

값이 index 0보다 작거나 컬렉션의 마지막 인덱스보다 큰 경우

TreeNode 이 인덱스로 할당되는 인덱스는 이미 다른 인덱스 또는 다른 TreeView 컨트롤에 할당되어 있습니다.

예제

다음 코드 예제에서는 속성이 "Node0"으로 TreeView 설정된 경우 TreeNode.Text 에서 첫 번째 TreeNode 속성을 제거합니다. 를 Button 클릭하면 메서드를 사용하여 RemoveAt 첫 번째 TreeNodeTreeView 항목이 삭제됩니다. 이 예제에서는 에 a 및 a TreeViewButton 만들어야 합니다 Form. 첫 번째 TreeNode 텍스트 TreeView 속성은 "Node0"이어야 합니다.

void button2_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
{
   // Delete the first TreeNode in the collection
   // if the Text property is S"Node0."
   if ( this->treeView1->Nodes[ 0 ]->Text->Equals( "Node0" ) )
   {
      this->treeView1->Nodes->RemoveAt( 0 );
   }
}
private void button2_Click(object sender, EventArgs e)
{
   // Delete the first TreeNode in the collection 
   // if the Text property is "Node0." 
   if(this.treeView1.Nodes[0].Text == "Node0")
   {
      this.treeView1.Nodes.RemoveAt(0);
   }
}
Private Sub button2_Click(sender As Object, e As EventArgs) Handles button2.Click
   ' Delete the first TreeNode in the collection 
   ' if the Text property is "Node0." 
   If Me.treeView1.Nodes(0).Text = "Node0" Then
      Me.treeView1.Nodes.RemoveAt(0)
   End If
End Sub

설명

특정 위치에 개체를 할당 TreeNode 하거나 개체를 TreeNodeCollection검색하려면 특정 인덱스 값을 사용하여 컬렉션 개체를 참조할 수 있습니다. 인덱스 TreeNodeCollection 값은 0부터 시작하는 인덱스입니다.

추가 정보

적용 대상

Item[String]

Source:
TreeNodeCollection.cs
Source:
TreeNodeCollection.cs
Source:
TreeNodeCollection.cs
Source:
TreeNodeCollection.cs
Source:
TreeNodeCollection.cs

컬렉션에서 지정된 키를 가진 트리 노드를 가져옵니다.

public:
 virtual property System::Windows::Forms::TreeNode ^ default[System::String ^] { System::Windows::Forms::TreeNode ^ get(System::String ^ key); };
public virtual System.Windows.Forms.TreeNode this[string key] { get; }
public virtual System.Windows.Forms.TreeNode? this[string? key] { get; }
member this.Item(string) : System.Windows.Forms.TreeNode
Default Public Overridable ReadOnly Property Item(key As String) As TreeNode

매개 변수

key
String

TreeNode 컬렉션에서 검색할 이름입니다.

속성 값

TreeNode 지정된 키가 있는 키입니다.

설명

속성은 Name 에 있는 키에 TreeNodeTreeNodeCollection해당합니다.

키 비교는 대/소문자를 구분하지 않습니다. 매개 변수 또는 keynull 빈 문자열이면 속성이 Item[] 반환됩니다 null.

적용 대상