views:

976

answers:

3

I'm looking for the easiest solution to implement a folder browse dialog with checkboxes in front of the directories in my (C#) WinForms project.

I saw this kind of dialog in Vista in the backup center. It was just like a normal Folder browse dialog, but in front of every folder there was a checkbox. If you checked a folder, all folders and files in it were checked as well, while you could still deselect them separately afterwards.

If there's no prefab control or whatever for this, then what's the easiest way to either: - Manipulate a normal folder browse dialog to include the checkbox functionality; or - Manipulate a TreeView control to use Shell icons for paths (so the correct system icons for Desktop, My Music, normal folders, files, etc) so I can build one myself?

Note: I want the dialog/control to show both files and folders.

Thanks in advance for any tips and hints. =)

A: 

The simplest way to implement something like this would be to use a standard TreeView control with the CheckBoxes property set to true. You should also be able to use images with it if you'd like to add a little folder image next to each node.

See this MSDN article for more info.

BFree
+3  A: 

Start with tree vew. (you will have to take care of dynamically fetching children yourself, though).

If you don't care about the Explorer Namespace (i. e. having Control Panel below My Computer, or Desktop with Recycle Bin, Network Neigborhood and some more stuff below), and only need files on drives with drive letters, you can start with enumerating drive letters (using System.IO.Directory.GetLogicalDrives).

You can get the shell icons by calling ExtendedFileInfo.GetIconForFilename from the ManagedWinapi library (http://mwinapi.sourceforge.net/), which works both for files and folders.

mihi
A: 

The FolderBrowserDialog does not support check boxes. Take a look at FolderView control which displays multi-state check boxes next to folders and files.

logicnp