Back to Devexpress

DXFileDialog.Filter Property

wpf-devexpress-dot-xpf-dot-dialogs-dot-dxfiledialog-e18a60e2.md

latest2.3 KB
Original Source

DXFileDialog.Filter Property

Gets or sets the current file name filter string, which determines the choices that appear in a file dialog.

Namespace : DevExpress.Xpf.Dialogs

Assembly : DevExpress.Xpf.Dialogs.v25.2.dll

NuGet Package : DevExpress.Wpf.Dialogs

Declaration

csharp
public string Filter { get; set; }
vb
Public Property Filter As String

Property Value

TypeDescription
String

The file filtering options available in the file dialog.

|

Remarks

For each filtering option, the filter string contains a description of the filter, followed by the vertical bar (|) and the filter pattern. The strings for different filtering options are separated by the vertical bar.

The following is an example of a filter string:

Text files (*.txt)|*.txt|All files (*.*)|*.*

You can add several filter patterns to a filter by separating the file types with semicolons, for example:

Image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|All files (*.*)|*.*

Use the DXFileDialog.FilterIndex property to set which filtering option is shown first to the user.

The code sample below demonstrates how to define filters that allow end-users to see images or all files.

csharp
private void button_Click(object sender, RoutedEventArgs e) {
    var fileDialog = new DXOpenFileDialog();
    fileDialog.Filter = "Image Files|*.BMP;*.JPG;*.GIF|All files|*.*";
    fileDialog.ShowDialog();
}
vb
Private Sub button_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
    Dim fileDialog = New DXOpenFileDialog()
    fileDialog.Filter = "Image Files|*.BMP;*.JPG;*.GIF|All files|*.*"
    fileDialog.ShowDialog()
End Sub

See Also

DXFileDialog Class

DXFileDialog Members

DevExpress.Xpf.Dialogs Namespace