Filter Property (ACommonDialog)

Returns or sets the filters that are displayed in the Typelist box of a dialog box.

Syntax

Object.Filter [ = sFilter ]

The Filter property syntax has the following parts:

 

Name

Type

Description

Object

ACommonDialog

ACommonDialog control

sFilter

BString

The filters that are displayed in the Typelist box of a dialog box.

Comments

A filter specifies the type of files that are displayed in the dialog box's file list box. For example, selecting the filter *.txt displays all text files.

Use this property to provide the user with a list of filters that can be selected when the dialog box is displayed.

Use the pipe ( | ) symbol (ASCII 124) to separate the description and filter values. Do not include spaces before or after the pipe symbol, because these spaces will be displayed with the description and filter values.

The following code shows an example of a filter that enables the user to select text files or graphic files that include bitmaps and icons:

Text (*.txt)|*.txt|Pictures (*.bmp;*.ico)|*.bmp;*.ico

When you specify more than one filter for a dialog box, use the FilterIndex property to determine which filter is displayed as the default.

Example

The following example will set the filter to display only files with the extension .prg:

cdlg1.Filter="Program (*.prg)|*.prg"

Applies to

ACommonDialog

See Also

DefaultExt, FileName, FilterIndex