Click here to Skip to main content
15,917,005 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
In treeView1 I have the filenames and directories...

For example...
Folder1Name
File1Name
Folder2Name
File2Name



In treeview2 I have the full filename and full directory...

For example...
C:\Folder1Name
C:\Folder1Name\File1Name.ext
C:\Folder2Name
C:\Folder2Name\File2Name.ext


I want to set treeview1 = treeview2 so that when the user clicks on treeview1 it can open the files without the user having to look at the whole directory name from treeview2...any help appreciated. Thank you!
Posted
Comments
Sergey Alexandrovich Kryukov 2-Mar-15 16:21pm    
To start with, please tell as what do you mean by the type TreeView. Which one? Full type name, please.
And what's the problem? What have you tried so far?
—SA
CBO1987 2-Mar-15 16:46pm    
In the treeView1_AfterSelect when the user clicks on something I want it to be selected to the same part of the index as treeView2

I tried something like
treeView1.SelectedNodes.Node = treeview2.SelectedNodes.Node

It works like if you click on a node in treeView1...treeView2 will actually open it up so index[0] of treeview1 would be equal to index[0] of treeview2 and so on

I am using it to create an mp3 player ... treeView1 would be the folder and song names and treeView2 would be the file directories/file names and extensions. I already have the treeviews populated but am not sure how to set them equal to each other. Hopefully this makes more sense. Sorry I am new to programming.
BillWoodruff 2-Mar-15 19:15pm    
This is easily accomplished, but the strategy used will depend on how you populate the TreeViews, are you doing it using databinding, or are you doing it by reading Directories and getting FileInfos, etc., and then creating the Nodes yourself ?

Another factor, if you are not using databinding, is whether you are parsing recursively ... folders within folders within folders ... or, if you the folders you parse contain only filepaths.

The .Tag property worked! Thank you very much!
 
Share this answer
 
One idea is, when you are filling treeview1 set the Tag property for each node to hold the information.
TreeNode.Tag Property
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900