My DataBase Table Structure is like this :
ID(Primary Key ) , Title (Nvarchar) , ParentID (this is the ID of current table)
and the 'ParentID' of first node (root) is valued = -1 i loaded this data in Memory.(for example in a list of class) how can i add the items with a loop or something else to TreeView ?
Just order your data by ParentID, first results will be root one (-1). Then use
thats how u make sure all previous nodes will be already in tree, and find them by unique key (ID).
I did wrote this code :
how is it?
You can loop over data and create TreeNodes that contains the data you want to display. You can also parent the nodes as you see fit (if needed).
You can then add the treenodes to the treeview's node collection.