VB.Net Tutorial/GUI/FolderBrowserDialog

Материал из VB Эксперт
Перейти к: навигация, поиск

Get the SelectedPath FolderBrowserDialog

Imports System.Windows.Forms
Public Class Tester
    Public Shared Sub Main
        Dim DirectoryBrowser As System.Windows.Forms.FolderBrowserDialog
        DirectoryBrowser = New System.Windows.Forms.FolderBrowserDialog
        DirectoryBrowser.Description = "Which directory do you want to use?"
        If (DirectoryBrowser.ShowDialog() = Windows.Forms.DialogResult.OK) Then
            Console.WriteLine(DirectoryBrowser.SelectedPath)
        End If
    End Sub
End Class

Set Properties for FolderBrowserDialog

Imports System.Windows.Forms
public class FolderBrowserDialogProperty
   public Shared Sub Main
        Dim FolderBrowserDialog1 As FolderBrowserDialog = New System.Windows.Forms.FolderBrowserDialog
        With FolderBrowserDialog1
            .RootFolder = Environment.SpecialFolder.rumonProgramFiles
            .SelectedPath = "C:\Temp"
            .ShowNewFolderButton = False
            .Description = "Use the tree below to select a folder:"
        End With
        If FolderBrowserDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            Console.WriteLine(FolderBrowserDialog1.SelectedPath)
        End If
   End Sub
End class