TreeNode.Index Propiedad

Definición

Obtiene la posición del nodo de árbol en la colección de nodos de árbol.Gets the position of the tree node in the tree node collection.

public:
 property int Index { int get(); };
public int Index { get; }
member this.Index : int
Public ReadOnly Property Index As Integer

Valor de propiedad

Valor de índice de base cero que representa la posición del nodo de árbol en la colección de Nodes.A zero-based index value that represents the position of the tree node in the Nodes collection.

Ejemplos

En el ejemplo de código siguiente Text se Index muestran los valores de TreeNode las propiedades y Parent del representado por TreeView.SelectedNodela propiedad de.The following code example displays the Text and Index property values of the TreeNode represented by the Parent property of the TreeView.SelectedNode. Este ejemplo requiere que tenga un Form TreeView control en él.This example requires that you have a Form with a TreeView control on it. TreeView Debe tener al menos dos nodos raíz, cada uno con al menos un nodo secundario.The TreeView should have at least two root nodes, each having at least one child node.

private:
   void treeView1_AfterSelect( Object^ /*sender*/, TreeViewEventArgs^ e )
   {
      /* Display the Text and Index of the
            * selected tree node's Parent. */
      if ( e->Node->Parent != nullptr && e->Node->Parent->GetType() == TreeNode::typeid )
      {
         statusBar1->Text = String::Format( "Parent: {0}\n Index Position: {1}", e->Node->Parent->Text, e->Node->Parent->Index );
      }
      else
      {
         statusBar1->Text = "No parent node.";
      }
   }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{  
   /* Display the Text and Index of the 
    * selected tree node's Parent. */
   if(e.Node.Parent!= null && 
     e.Node.Parent.GetType() == typeof(TreeNode) )
   {
      statusBar1.Text = "Parent: " + e.Node.Parent.Text + "\n"
         + "Index Position: " + e.Node.Parent.Index.ToString();
   }
   else
   {
      statusBar1.Text = "No parent node.";
   }
}
Private Sub treeView1_AfterSelect(sender As Object, _
  e As TreeViewEventArgs) Handles treeView1.AfterSelect
   ' Display the Text and Index of the 
   ' selected tree node's Parent. 
   If (e.Node.Parent IsNot Nothing) 
      If (e.Node.Parent.GetType() Is GetType(TreeNode)) Then
         statusBar1.Text = "Parent: " + e.Node.Parent.Text + _
           ControlChars.Cr + "Index Position: " + e.Node.Parent.Index.ToString()
      End If
   Else
      statusBar1.Text = "No parent node."
   End If
End Sub 

Se aplica a