Click here to Skip to main content
15,902,299 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am having a tree view control.

I have given all drives as nodes.

If I select a drive it should select all the folders and its subfolders.

How to do this. I use Checkbox to select these drives
Posted

1 solution

You do understand that by placing the drive names in a TreeView, that's all you have. You must supply code that adds the directory nodes beneath the drive nodes.

I strongly suggest that you only descend one level at a time. For example only add directory nodes immediately beneath a selected drive. If one of those directories is selected, only expand the nodes to include the the selected directory's subdirectories. Otherwise the user will be faced with long wait times.

Also, there is a control to do what you appear to want. It's called Folder Browser Dialog[^].
 
Share this answer
 
Comments
KUMAR619 5-Apr-14 10:56am    
You are right but using folder dialog box we can select only one directory.

How to select multiple folders using C#
gggustafson 5-Apr-14 11:37am    
Usually a directory is opened and some action is taken; then another directory is opened and the action is again taken. Selecting multiple directories does not make sense to me.

Please explain exactly what you are trying to accomplish?

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