在 FolderBrowserDialog 中显示文本框

Kaz*_*ahi 5 vb.net folderbrowserdialog

我如何在 FolderBrowserDialog 中显示文本框,如下图所示, 在此处输入图片说明

Han*_*ant 5

这不是直接可能的,您必须回退到使用 shell 函数。项目 + 添加引用,浏览选项卡,选择 c:\windows\system32\shell32.dll。如何在 Winforms 应用程序中使用它的示例:

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
Run Code Online (Sandbox Code Playgroud)