ExtendedTreeViewItem Property
This can be used to get a tree node by name from the tree view (a root node or any child at any
level).
Namespace: EWSoftware.ListControlsAssembly: EWSoftware.ListControls (in EWSoftware.ListControls.dll) Version: 2023.4.9.0
public TreeNode this[
string name
] { get; }
Public ReadOnly Default Property Item (
name As String
) As TreeNode
Get
public:
property TreeNode^ default[String^ name] {
TreeNode^ get (String^ name);
}
member Item : TreeNode with get
- name String
- The name of the tree node to retrieve.
TreeNodeReturns the tree node that was found or null if it was not found.
The tree's nodes are searched recursively for the first node with a name that matches the
specified value. The value is case-sensitive. Note that node names do not have to be unique.
Only the first node found is returned even if other nodes further down the tree have an identical
name.
string name = txtFindName.Text.Trim();
if(name.Length == 0)
{
MessageBox.Show("Enter a node name to find", "Tree View Demo",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
// Simply use the indexer with the name of the node. Note that
// node names aren't necessarily unique (they are in the demo) so
// it returns the first node found with the given name.
TreeNode node = tvExtTree[txtFindName.Text];
if(node != null)
{
tvExtTree.SelectedNode = node;
node.EnsureVisible();
tvExtTree.Focus();
}
else
MessageBox.Show("Unable to find node named '" + name + "'. " +
"The name is case-sensitive. Use the tool tips or enable " +
"the form DrawNode events to verify the node names and " +
"try again.", "Tree View Demo", MessageBoxButtons.OK,
MessageBoxIcon.Error);
Dim name As String = txtFindName.Text.Trim()
If name.Length = 0 Then
MessageBox.Show("Enter a node name to find", "Tree View Demo",
MessageBoxButtons.OK, MessageBoxIcon.Error)
Return
End If
' Simply use the indexer with the name of the node. Note that node names
' aren't necessarily unique (they are in the demo) so it returns the first
' node found with the given name.
Dim node As TreeNode = tvExtTree(txtFindName.Text)
If node IsNot Nothing Then
tvExtTree.SelectedNode = node
node.EnsureVisible()
tvExtTree.Focus()
Else
MessageBox.Show("Unable to find node named '" & name & "'. " & _
"The name is case-sensitive. Use the tool tips or enable " & _
"the form DrawNode events to verify the node names and " & _
"try again.", "Tree View Demo", MessageBoxButtons.OK, _
MessageBoxIcon.Error)
End If
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.