article

VB.NET BrowseForFolder Dialog

Email
Submitted on: 1/1/2015 4:44:00 AM
By: bleh (from psc cd)  
Level: Beginner
User Rating: By 6 Users
Compatibility: VB.NET
Views: 1976
 
     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.


 
				
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


Other 2 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.