Creatin Directory Tree Control With Check Boxes

This program displays entire directory structure of all the drives in a tree control. The tree control also displays check boxes in front of each directory which can be used to select or deselect the directory. We have created round check boxes instead of traditional square check boxes. User can check or uncheck the directory by clicking on the check box. Whether all of the sub-directories are checked can be known by the grayed bitmap displayed in front of the parent directory.

Generally directory tree with check boxes is needed while creating an anti-viral software in which user can check or uncheck the directories depending upon whether he wants to scan the directory or not.
Check boxes actually are bitmaps using which image list is created and images are loaded depending on the status (Checked/Unchecked) of the directory.

In this program, firstly only the drives are displayed with checked status. When user double clicks on the label or clicks on the plus sign the tree is expanded and directories of that drive are displayed in. Since the drive is checked all the directories also are displayed with checked sign. Now if the drive is unchecked all the directories also become unchecked.
This control only displays directories. You can anytime modify this program to display files of the selected directory.


No comments: