Search code examples
vb.netfolderbrowserdialog

show text box in FolderBrowserDialog


how i can show textbox in FolderBrowserDialog like below image, enter image description here


Solution

  • This is not directly possible, you have to fallback to using the shell function. Project + Add Reference, Browse tab, select c:\windows\system32\shell32.dll. An example of how to use it in a Winforms app:

    Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        Dim options As Integer = &H40 + &H200 + &H20
        options += &H10   '' Adds edit box
        Dim shell = New Shell32.ShellClass
        Dim root = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
        Dim folder = CType(shell.BrowseForFolder(CInt(Me.Handle), _
            "Select folder", options, root), Shell32.Folder2)
        If folder IsNot Nothing Then
            MsgBox("You selected " + folder.Self.Path)
        End If
    End Sub