C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Winforms Controls »

Working with FolderBrowserDialog in VB.NET


Posted Date: 04 Nov 2009    Resource Type: Code Snippets    Category: Winforms Controls
Author: Abhisek PandaMember Level: Gold    
Rating: 1 out of 5Points: 10



First create a window application in VB.Net and add a FolderBrowserDialog controll to it. Also add a textbox(txtFolder) and button( btnBrowseFolders).

The button's work here is to open the FolderBrowserDialog and user can select any folder or file to be displayed in the text box. Now double click on the button and add the following code in it.


Private Sub btnBrowseFolders_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowseFolders.Click
Try
With fldlgList
'set the RootFolder
.RootFolder = Environment.SpecialFolder.Personal
' optional Description to provide additional instructions.
Description = "Select the directory you want to use as the default."
ShowNewFolderButton = True
'Showing the selected folder in the textbox
If ShowDialog = Windows.Forms.DialogResult.OK Then
txtFolder.Text = .SelectedPath
End If

End With

Catch ex As Exception

MsgBox(ex.Message, MsgBoxStyle.Exclamation, Me.Text)

End Try

End Sub

DESCRIPTION:-



After creating a new FolderBrowserDialog, you have to set the RootFolder to the location from which to start browsing. You can choose from the list of system special folders, such as Program Files, Programs, System, or Startup, which contain common information.

RootFolder = Environment.SpecialFolder.Personal


We can give user optional information about the bowser using the Description property.

Description = "Select the directory you want to use as the default."


You can use the ShowNewFolderButton property to control if the user is able to create new folders via the New Folder button in the browse dialogue window.

ShowNewFolderButton = True











Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
FolderBrowserDialog  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Creation of Window Explorer using vb.net
Previous Resource: GUI Multiplication Table
Return to Discussion Resource Index
Post New Resource
Category: Winforms Controls


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use