Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB.Net - Windows Forms FolderBrowserDialog Not Opening

Status
Not open for further replies.

jmarkus

Technical User
Oct 15, 2002
124
CA
I'm trying to present the user with a folder dialog to pick a destination directory when they click a button.

I can't get the sub that handles this to show the dialog.

I've stripped down my sub to just the following bare bones code and it still hangs and doesn't show the dialog. How can I debug this?

Code:
Private Sub Button13_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button13.Click
[indent]Dim folderBrowserDialog1 As New FolderBrowserDialog
folderBrowserDialog1.ShowDialog()
[/indent]
End Sub

Thanks,
Jeff
 
This works for me - Visual Studio 2015:

Code:
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim folderBrowserDialog1 As New FolderBrowserDialog

        folderBrowserDialog1.ShowDialog()
[green]
        'If FolderBrowserDialog1.ShowDialog() = DialogResult.OK Then
        '    MsgBox(folderBrowserDialog1.SelectedPath)
        'End If[/green]
    End Sub

Try it with a brand new Project in VS just to test it.

Have fun.

---- Andy

There is a great need for a sarcasm font.
 
It works for me in a new project, but this is in some existing VB code which I am adding to.

Any idea what would cause it to trip up?

Jeff
 
Since the FolderBrowserDialog class in System.Windows.Forms has such an awful user interface; maybe someone wrote their own version within the project you are working with and that custom version isn't working just right.

Try changing
Code:
Dim folderBrowserDialog1 As New FolderBrowserDialog
' to
Dim folderBrowserDialog1 As New System.Windows.Forms.FolderBrowserDialog

and see if that makes any difference. If it does then you probably have a renegade version of FolderBrowserDialog somewhere in your project.
 
Nope, no other FolderBrowserDialog exists in the code.

As a "let's see what happens" I put an OpenFileDialog in place of the FolderBrowserDialog, and that worked. Unfortunately that doesn't let me return just a folder.

Sigh.
Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top