Articles in this section
Category / Section

How to retrieve the TreeNodeAdv from TreeNodeAdvCollection without performing iteration process in the WinForms TreeViewAdv?

2 mins read

Retrieve the TreeNodeAdv from TreeNodeAdvCollection

In the WinForms TreeView, it is possible to retrieve a particular TreeNodeAdv based on the custom property. Refer to the following steps.

1. Load TreeNodeAdv to custom collection while adding the TreeNodeAdv to TreeViewAdv nodes collection.

2. Then, you can retrieve the TreeNodeAdv based on index value from the custom collection.

C#

//Stores the TreeNodeAdv to list.
private List<TreeNodeAdv> nodecollection = new List<TreeNodeAdv>();
//Initializes the TreeNodeAdv
private TreeNodeAdv node = new TreeNodeAdv();
for (int nodeId = 0; nodeId <= 10000; nodeId++)
{
    //Custom node for ID propety
    CustomTreeNodeAdv customNode = new CustomTreeNodeAdv();
    customNode.ID = nodeId;
    customNode.Text = "Node" + nodeId.ToString();
    this.treeViewAdv1.Nodes.Add(customNode);
    nodecollection.Add(customNode);
}
//Gets the TextBox value
int textvalue = Int32.Parse(this.integerTextBox1.Text);
//Gets the TreeNodeAdv from list
node = nodecollection[textvalue];
//Shows the selected node text
MessageBox.Show(node.Text);

VB

'Stores TreeNodeAdv to list.
Private nodecollection As New List(Of TreeNodeAdv)()
'Initializes the TreeNodeAdv
Private node As New TreeNodeAdv()
For nodeId As Integer = 0 To 10000
     'Custom node for ID propety
     Dim customNode As New CustomTreeNodeAdv()
     customNode.ID = nodeId
     customNode.Text = "Node" & nodeId.ToString()
     Me.treeViewAdv1.Nodes.Add(customNode)
     nodecollection.Add(customNode)
Next nodeId
'Gets the text box value
Dim textvalue As Integer = Int32.Parse(Me.integerTextBox1.Text)
'Gets the node from list
node = nodecollection(textvalue)
'Shows the selected node text
MessageBox.Show(node.Text)

Samples:

C#: https://www.syncfusion.com/downloads/support/directtrac/138428/TreeNodeAdv-1281820906.zip

VB: https://www.syncfusion.com/downloads/support/directtrac/138428/TreeNodeAdv_VB-985453358.zip

 

Conclusion

I hope you enjoyed learning about how to retrieve the TreeNodeAdv from TreeNodeAdvCollection without performing iteration process in the WinForms TreeViewAdv.

You can refer to our  WinForms TreeView’s feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms TreeView documentation to understand how to present and manipulate data. 

For current customers, you can check out our WinForms components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our WinForm TreeView and other WinForms components.

If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied