VB.Net/GUI/Dialog Folder Browser

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

Folder Browser Dialog: print Selected Folder

Imports System
Imports System.Collections
Imports System.ruponentModel
Imports System.Windows.Forms
Imports System.Data
Imports System.Configuration
Imports System.Resources
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.IO
Imports System.Drawing.Printing

Public Class MainClass
    Shared Sub Main()
        "Declare a FolderBrowserDialog object
        Dim objFolderBrowserDialog As New FolderBrowserDialog
        "Set the FolderBrowserDialog control properties
        objFolderBrowserDialog.Description = "Select your favorite folder:"
        objFolderBrowserDialog.RootFolder = Environment.SpecialFolder.Personal
        objFolderBrowserDialog.ShowNewFolderButton = True
        "Show the Browse For Folder dialog
        If objFolderBrowserDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
            "Display the selected folder
            System.Console.WriteLine(objFolderBrowserDialog.SelectedPath)
        End If
        "Clean up
        objFolderBrowserDialog.Dispose()
        objFolderBrowserDialog = Nothing
    End Sub
End Class


Folder Browser Dialog: set Description

Imports System
Imports System.Data
Imports System.Windows.Forms
Imports System.Drawing
Public Class MainClass
    
    Shared Sub Main()
        Dim dlgFolder As System.Windows.Forms.FolderBrowserDialog
        dlgFolder = New System.Windows.Forms.FolderBrowserDialog

        dlgFolder.Description = "Select the folder that contains the XML files."
        If dlgFolder.ShowDialog() = DialogResult.OK Then
            Console.WriteLine( dlgFolder.SelectedPath)
        End If
    End Sub
End Class


Folder Browser Dialog: set selected folder

Imports System
Imports System.Data
Imports System.Windows.Forms
Imports System.Drawing
Public Class MainClass
    
    Shared Sub Main()
        Dim dlgFolder As System.Windows.Forms.FolderBrowserDialog
        dlgFolder = New System.Windows.Forms.FolderBrowserDialog

        dlgFolder.SelectedPath = "C:\"
        If dlgFolder.ShowDialog() = DialogResult.OK Then
            Console.WriteLine( dlgFolder.SelectedPath)
        End If
    End Sub
End Class