Populate TreeView node by clicking item in ListView
-
Hello all. I am new here; a student of programming! I am developing an app similar to Windows Explorer. I have everything working great. But I have one question: Can anyone tell me what I may need to do to be able to click on a directory in the Listview and repopulate the Treeview in the left pane?:confused: Any help would be much appreciated!
-
Hello all. I am new here; a student of programming! I am developing an app similar to Windows Explorer. I have everything working great. But I have one question: Can anyone tell me what I may need to do to be able to click on a directory in the Listview and repopulate the Treeview in the left pane?:confused: Any help would be much appreciated!
MrColeyted, Listen for the ListView.SelectedIndexChanged event. http://msdn2.microsoft.com/en-us/library/system.windows.forms.listview.onselectedindexchanged.aspx[^] Then do TreeView.Nodes.Add(WhatYouWantToAdd); http://msdn2.microsoft.com/en-us/library/system.windows.forms.treeview.aspx[^] Regards, Gareth.
-
MrColeyted, Listen for the ListView.SelectedIndexChanged event. http://msdn2.microsoft.com/en-us/library/system.windows.forms.listview.onselectedindexchanged.aspx[^] Then do TreeView.Nodes.Add(WhatYouWantToAdd); http://msdn2.microsoft.com/en-us/library/system.windows.forms.treeview.aspx[^] Regards, Gareth.
Thanks for the feedback, but I have researched these things and I don't see how to do what I need, which is not add a node, but rather redraw the treeview to repopulate an existing node. For example: if I click the program files directory in the treeview, the directory is expanded in the treeview to show all of the folders; all of the folders and files are displayed in the listview. What I need to do is this: by clicking on a folder in the listview, lets say the Adobe folder, I want the Adobe folder in the treeview to be expanded to show all of the folders one level under the Adobe folder. Of course this should work for as many clicks in the listview as the user performs. Any suggestions?:confused: