03-22-2013 06:41 AM
Hi All ,
I am using a tree view control for populating my directory structure which may contain some sub folders and some files.
Want i want to do is, I want to select particular item/items from tree view and add it to different list(on clicking add button).
If i select only single file(chile element in tree view) it should get added to list.
But if I am selecting folder from tree view(parent item) all the files inside that folder should get added to the list.
I am not able to acheive last functionality. I am not able to identify whether the selected item from tree view is child or parent? Is there any property for that..I tried with properties like get parent , get child but its not working...
Am i doing it correctly? Can someone help me in this?
Thanks in advance
03-22-2013 11:56 PM - edited 03-23-2013 12:10 AM
When you say 'tree view control' is it a normal tree control on the control palette?
If so, this is what I do. Other people may have a different idea.
When you populate the tree, simply create an array of all tags that exist within the tree. Use {File/Folder Type};{Path} as a Tag Value of a tree element. For example, C:\test.txt becomes "File;C:\test.txt". C;\Users\Name becomes "Folder;C:\Users\Name"
If a selected value begins with 'File', then you can simply add the remaining value to the list.
If a selected value begins with 'Folder', then loop through the array to look for elements that start with 'File' and also includes the selected folder path within its file path. Then you can tell all files within the folder. This way you don't have to look at the tree properties or methods for children or parents.
Hope it helps.
03-27-2013 06:58 AM
This means first we have to edit the tagnames as per file and foler and then depending on the selection we can check whether file is selected or folder is selected?
I was thinking there could be a method/property to identify what the item is whether parent /child?
Thanks for the reply.
03-28-2013 12:16 PM
Can you explain how you currently populate the tree more in detail? What do you use as a tag value?
03-31-2013 10:58 PM
Hi
Currently I am using path of the folder/file as the tag value while populating the tree.
For eg: if folder is in c drive tag would be C:\folder name .
What I understood from above reply is while populating only i have to add differentiation for file and folder along with the path and then add it to the tag value.When the item is selected , check its tag and identify whether it is file or folder.