VB.Net Tutorial/GUI/SaveFileDialog — различия между версиями

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

Текущая версия на 12:57, 26 мая 2010

SaveFileDialog filter and selected file name,

Imports System.Windows.Forms
public class FileOpenDialogFilter
   public Shared Sub Main
        Dim saveFileDialog1 As System.Windows.Forms.SaveFileDialog
        saveFileDialog1 = New System.Windows.Forms.SaveFileDialog()
        saveFileDialog1.CreatePrompt = True
        saveFileDialog1.FileName = "doc1"
        saveFileDialog1.Filter = "Word (*.doc) |*.doc;*.rtf|(*.txt) |*.txt|(*.*) |*.*"
        If saveFileDialog1.ShowDialog() = DialogResult.OK Then
            Console.WriteLine(saveFileDialog1.FileName)
        End If
   End Sub
End class

Set InitialDirectory for SaveFileDialog

Imports System.Windows.Forms
public class SaveFileDialogWith
   public Shared Sub Main
        Dim SaveFileDialog1 As SaveFileDialog = New System.Windows.Forms.SaveFileDialog
        With SaveFileDialog1
            .DefaultExt = ".txt"
            .Filter = "Text Files|*.txt"
            .InitialDirectory = "C:\My Documents"
        End With
        If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            Console.WriteLine(SaveFileDialog1.FileName)
        End If
   End Sub
End class