You can bind TreeView to a list containing objects that are accessed by using index values.
Here is a sample code that first creates a class Products and creates an instance of List<T> belonging to System.Collections.Generic. Then it binds the TreeView control to the list and displays the data from the list in a hierarchical form when the Data Generate button is clicked.
The following code snippet creates a class Products.cs.
The following code snippets binds TreeView to the list.
Once you have clicked the Data Generate button after running the code, the following output appears.