README.md
December 5, 2022 ยท View on GitHub
Description
UPDATED 11JUN02 - Sorry It took me so long to fix this code after the site had been hacked. Regardless, here is the VB.NET code. | This will show the Browse For Folder dialog.
More Info
| Submitted On | |
| By | bleh |
| Level | Beginner |
| User Rating | 4.8 (29 globes from 6 users) |
| Compatibility | VB.NET |
| Category | GUIs |
| World | .Net (C#, VB.net) |
| Archive File |
Source Code
Extending The Browse For Folder Dialog Class For VB.NET
This code is simpily extending the Browse For Folder Dialog class that was on posted on PSC by Chris Andersen. After using his code, I was interested in knowing if there was any additional options available aside from just being able to set the title. I consulted the MSDN, and posted it under the C# section of PSC. Here is VB.NET version of that code. The above screen shot is showing the Browse For Folder dialog with StartLocation set to "MyDocuments" and Style set to "BrowseForEverything"
.StartLocation
The directory in which the browse dialog will start at. (duh) I haven't found a way to specifiy a certain path, like C:\PSC or something of that nature, but there are a number of members that we can use. They are:
- Desktop
- Favorites
- MyComputer
- MyDocuments
- MyPictures
- NetAndDialUpConnections
- NetworkNeighborhood
- Printers
- Recent
- SendTo
- StartMenu
- Templates
.Style
They style of the browse dialog. We have a few different options to choose from.
- BrowseForComputer
- BrowseForEverything
- BrowseForPrinter
- RestrictToDomain
- RestrictToFilesystem
- RestrictToSubfolders
- ShowTextBox
The Code
Here's an example of how to use the above methods in the Browse For Folder dialog.
Public Class BrowseForFolder
Inherits System.Windows.Forms.Design.FolderNameEditor
Dim bDialog As New FolderBrowser()
Public Function BrowseDialog(ByVal sTitle As String)
With bDialog
.Style = FolderBrowserStyles.BrowseForEverything
.StartLocation = FolderBrowserFolder.Desktop
.Description = sTitle
.ShowDialog()
BrowseDialog = .DirectoryPath()
End With
End Function
End Class
Useage:
Call the class like so:
Dim myDialog As New BrowseForFolder()
MsgBox(myDialog.BrowseDialog("My Dialog Title Here"))
Make sure you add a reference to the System.Windows.Forms.dll in your Solution Explorer!
It's pretty simple. Thanks again to Chris Anderson for the or