I am trying to prepare the tree view control from folowing strings.
"US|New York|D.M.Street"
"US|New York|ShoppingMall"
"INDIA|Dehli|G.M. Road"
"INDIA|Mumbai|Harbour Street"
"US|Washington|WhiteHouse"
"INDIA|Dehli|Rajpath"
"INDIA|Mumbai|CST"
I want to populate the tree view from this collection in C#. in following manner
Country
|
US => NewYork ==========>D.M.Street
| | ==========>ShoppingMall
|
| Washinton==========>WhiteHouse
|
INDIA=>Dehli ==========>G.M. Road
| ==========>Rajpath
|
Mumbai ==========>CST
==========>Harbour Street
how i can prepare this ? usning collection or else way?
Here’s how I would approach this:
Create a class and a collection to hold a nested hierarchy of elements (this can be expanded later if more detail is needed).
Then parse your data into the collection (note that this will support any level of nesting in your record structure without a need to modify the code):
and this is the recursive method used to add the items to the tree