[2005] folderbrowserdialog ..how to handle "close" or "cancel" button
VB Code:
dim mypath as string=""
With FolderBrowserDialog1
.SelectedPath = My.Settings.defaultdir
.ShowNewFolderButton = False
.Description = "Choose your folder"
.ShowDialog()
If Len(.SelectedPath) Then mypath= .SelectedPath
End With
if mypath="" then exit sub
'rest of code here
i use that code to let users to select a folder.... with default directory shown when dialog is opened... but when i click on "close" or "cancel" in folderdialog....it still acts as if i selected a folder...(i.e. it continues....in the section of code).... i want it to exit sub when users pres "close" or "cancel"
Re: [2005] folderbrowserdialog ..how to handle "close" or "cancel" button
You need to get the DialogResult of the FolderBrowserDialog in your code.
Code:
Dim dlgResult As DialogResult
Dim mypath As String = ""
With FolderBrowserDialog1
.ShowNewFolderButton = False
.Description = "Choose your folder"
dlgResult = .ShowDialog()
If Len(.SelectedPath) Then mypath = .SelectedPath
End With
If dlgResult = Windows.Forms.DialogResult.Cancel Then
MessageBox.Show("Dialog was cancelled")
Else
MessageBox.Show("Selected Folder " & mypath)
End If
Re: [2005] folderbrowserdialog ..how to handle "close" or "cancel" button