TreeNode.Index Proprietà
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene la posizione del nodo della struttura ad albero nell'insieme di nodi della struttura ad albero.
public:
property int Index { int get(); };
public int Index { get; }
member this.Index : int
Public ReadOnly Property Index As Integer
Valore della proprietà
Valore di indice in base zero che rappresenta la posizione del nodo della struttura ad albero nell'insieme Nodes .
Esempio
Nell'esempio di codice seguente vengono visualizzati i Text valori delle proprietà e Index dell'oggetto TreeNode rappresentato dalla Parent proprietà dell'oggetto TreeView.SelectedNode. In questo esempio è necessario disporre di un Form oggetto con un TreeView controllo su di esso. Deve TreeView avere almeno due nodi radice, ognuno con almeno un nodo figlio.
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