Visual Studio 2008 folder browser dialog
Asked Answered
A

4

10

In Visual Studio 2008 there is a folder browser dialog that looks like this (very similar to file open dialog):

Dialog

Does anyone know how to invoke it from code?

Abad answered 9/8, 2009 at 9:11 Comment(0)
A
5

At the end I just used the VistaBridge library to open it.

Abad answered 10/9, 2009 at 20:39 Comment(1)
I have searched such dialog in VistaBridge and found nothing, what is the class name of FolderBrawser analog in VistaBridge?Mellette
W
21

If you're using C#, this solution is for you. Source code provided here: http://www.lyquidity.com/devblog/?p=136 (.NET Win 7-style folder select dialog). [Update: if site is dead, here's a wayback machine link.]

How does it work? It turns out that the ability to show a Vista-like dialog is present in .NET but the methods are not public. So the ShowDialog() method uses reflection to call CreateVistaDialog and pass in all the parameters. The technique to do this is taken from the Google code project FED.

You don't need to use a whole library like VistaBridge, or a Windows API code pack, to get a nice Folder Dialogue, just two small source files. Gives you a nice folder dialogue like this:

Weakness answered 17/3, 2013 at 1:27 Comment(5)
This solution works without using VistaBridge and it provides a fallback for XP and older.Jacqui
This is a great solution. It simply works and unlike Windows API code pack this has no license restrictions. Thank you!Glottochronology
It should be mentioned that the Reflector class is from Front-End for Dosbox and this is GPL v2. So it has license restrictions.Squier
July 2023: the linked site, lyquidity.com, appears to be gone.Udale
@Udale Wayback machine and download still works: web.archive.org/web/20230408013724/http://www.lyquidity.com/…Weakness
A
5

At the end I just used the VistaBridge library to open it.

Abad answered 10/9, 2009 at 20:39 Comment(1)
I have searched such dialog in VistaBridge and found nothing, what is the class name of FolderBrawser analog in VistaBridge?Mellette
O
1

Is this the pinvoke of SHBrowseForFolder, with the BIF_NEWDIALOGSTYLE style? If so there is an example on that page.

Overlong answered 9/8, 2009 at 11:8 Comment(0)
H
-2

Drag a FolderBrowserDialog component from the Dialogs tab of the Toolbox to the form. Add this code to you button handler.

if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
        {
            this.label1.Text = folderBrowserDialog1.SelectedPath;
        }
Horlacher answered 9/8, 2009 at 9:18 Comment(1)
Please look at the attached image. I want THAT folder browser dialog and not the regular ugly one.Abad

© 2022 - 2024 — McMap. All rights reserved.