Folder browse dialog with checkboxes?
Asked Answered
B

3

7

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. =)

Brown answered 22/4, 2009 at 17:35 Comment(0)
P
4

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.

Perpetrate answered 22/4, 2009 at 18:0 Comment(0)
F
0

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.

Flatworm answered 22/4, 2009 at 17:48 Comment(0)
S
0

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

Salvucci answered 10/7, 2009 at 4:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.