Aracılığıyla paylaş


FileDialog.Filter Özellik

Tanım

veya 'den hangi dosya türlerinin görüntüleneceğini belirleyen filtre dizesini OpenFileDialog alır veya SaveFileDialogayarlar.

public:
 property System::String ^ Filter { System::String ^ get(); void set(System::String ^ value); };
public string Filter { get; set; }
member this.Filter : string with get, set
Public Property Filter As String

Özellik Değeri

String Filtreyi içeren bir. Varsayılan değer olan Empty, filtre uygulanmadığı ve tüm dosya türlerinin görüntülendiği anlamına gelir.

Özel durumlar

Filtre dizesi geçersiz.

Örnekler

Aşağıdaki örneklerde, özelliği kullanılarak ayarlanabilen çeşitli filtre dizesi türleri gösterilmektedir Filter .

OpenFileDialog dlg = new OpenFileDialog();

// Show all files
dlg.Filter = string.Empty;

dlg.ShowDialog();
Dim dlg As New OpenFileDialog()

' Show all files
dlg.Filter = String.Empty

dlg.ShowDialog()
OpenFileDialog dlg = new OpenFileDialog();

// Show all files
dlg.Filter = null;

dlg.ShowDialog();
Dim dlg As New OpenFileDialog()

' Show all files
dlg.Filter = Nothing

dlg.ShowDialog()
OpenFileDialog dlg = new OpenFileDialog();

// Filter by Word Documents
dlg.Filter = "Word Documents|*.doc";

dlg.ShowDialog();
Dim dlg As New OpenFileDialog()

' Filter by Word Documents
dlg.Filter = "Word Documents|*.doc"

dlg.ShowDialog()
OpenFileDialog dlg = new OpenFileDialog();

// Filter by Excel Worksheets
dlg.Filter = "Excel Worksheets|*.xls";

dlg.ShowDialog();
Dim dlg As New OpenFileDialog()

' Filter by Excel Worksheets
dlg.Filter = "Excel Worksheets|*.xls"

dlg.ShowDialog()
OpenFileDialog dlg = new OpenFileDialog();

// Filter by PowerPoint Presentations
dlg.Filter = "PowerPoint Presentations|*.ppt";

dlg.ShowDialog();
Dim dlg As New OpenFileDialog()

' Filter by PowerPoint Presentations
dlg.Filter = "PowerPoint Presentations|*.ppt"

dlg.ShowDialog()
OpenFileDialog dlg = new OpenFileDialog();

// Filter by Office Files
dlg.Filter = "Office Files|*.doc;*.xls;*.ppt";

dlg.ShowDialog();
Dim dlg As New OpenFileDialog()

' Filter by Office Files
dlg.Filter = "Office Files|*.doc;*.xls;*.ppt"

dlg.ShowDialog()
OpenFileDialog dlg = new OpenFileDialog();

// Filter by All Files
dlg.Filter = "All Files|*.*";

dlg.ShowDialog();
Dim dlg As New OpenFileDialog()

' Filter by All Files
dlg.Filter = "All Files|*.*"

dlg.ShowDialog()
OpenFileDialog dlg = new OpenFileDialog();

// Filter by Word Documents OR Excel Worksheets OR PowerPoint Presentations 
//           OR Office Files 
//           OR All Files
dlg.Filter = "Word Documents|*.doc|Excel Worksheets|*.xls|PowerPoint Presentations|*.ppt" +
             "|Office Files|*.doc;*.xls;*.ppt" +
             "|All Files|*.*";

dlg.ShowDialog();
Dim dlg As New OpenFileDialog()

' Filter by Word Documents OR Excel Worksheets OR PowerPoint Presentations 
'           OR Office Files 
'           OR All Files
dlg.Filter = "Word Documents|*.doc|Excel Worksheets|*.xls|PowerPoint Presentations|*.ppt" & "|Office Files|*.doc;*.xls;*.ppt" & "|All Files|*.*"

dlg.ShowDialog()

Açıklamalar

veya Emptyise Filternull, tüm dosyalar görüntülenir ve klasörler her zaman görüntülenir.

özelliğini ayarlayarak Filter görüntülenecek dosya türlerinin bir alt kümesini belirtebilirsiniz. Her dosya türü, aşağıdaki gibi belirli bir dosya türünü temsil edebilir:

  • Word Belgeleri (*.doc)

  • Excel Çalışma Sayfaları (*.xls)

  • PowerPoint Sunuları (*.ppt)

Alternatif olarak, dosya türü aşağıdakiler gibi bir grup ilgili dosya türünü temsil edebilir:

  • Office Dosyaları (*.doc, *.xls, *.ppt)

  • Tüm Dosyalar (*. *)

Görüntülenen dosya türlerinin bir alt kümesini belirtmek için, özelliğini filtre uygulanacak bir veya daha fazla dosya türünü belirten bir dize değeriyle (filtre dizesi) ayarlarsınızFilter. Filtre dizesinin beklenen biçimi aşağıda gösterilmiştir:

FileType1[[|FileType2]...[|FileTypeN]]

Her dosya türünü açıklamak için aşağıdaki biçimi kullanırsınız:

Label|Extension1[[;Extension2]...[;ExtensionN]]

Etiket bölümü, aşağıdaki gibi dosya türünü açıklayan, insanlar tarafından okunabilir bir dize değeridir:

  • "belgeleri Word"

  • "Excel Çalışma Sayfaları"

  • "PowerPoint Sunuları"

  • "Office Dosyaları"

  • "Tüm Dosyalar"

Her dosya türü en az bir Uzantı ile açıklanmalıdır. Birden fazla Uzantı kullanılıyorsa, her Uzantı noktalı virgülle (";") ayrılmalıdır. Örnek:

  • "*.doc"

  • "*.xls;"

  • "*.ppt"

  • "*.doc;*.xls;*.ppt"

  • "*.*"

Geçerli dize değerlerinin Filter tam örnekleri aşağıda verilmiştir:

  • Word Documents|*.doc

  • Excel Worksheets|*.xls

  • PowerPoint Presentations|*.ppt

  • Office Files|*.doc;*.xls;*.ppt

  • All Files|*.*

  • Word Documents|*.doc|Excel Worksheets|*.xls|PowerPoint Presentations|*.ppt|Office Files|*.doc;*.xls;*.ppt|All Files|*.*

Filtreye dahil edilen her dosya türü, aşağıdaki şekilde gösterildiği gibi veya içindeki OpenFileDialogDosyalarSaveFileDialog: açılan listesine ayrı bir öğe olarak eklenir.

Aç İletişim Kutusunda FileDialog.Filter

Kullanıcı, filtreleme ölçütü olarak bu listeden bir dosya türü seçebilir. Varsayılan olarak, veya SaveFileDialog görüntülendiğinde OpenFileDialog listedeki ilk öğe (örneğin, ilk dosya türü) seçilir. Seçilecek başka bir dosya türünü belirtmek için, veya SaveFileDialog öğesini göstermeden OpenFileDialog önce özelliğini ayarlarsınız FilterIndex (çağrısı ShowDialogyaparak).

Şunlara uygulanır

Ayrıca bkz.