Visual Basic: CommonDialog Control
Filter Property (CommonDialog)
Returns or sets the filters that are displayed in the Type list box of a dialog box.
object.Filter [= description1 |filter1 |description2 |filter2...]
The Filter property syntax has these parts:
|object||An object expression that evaluates to an object in the Applies To list.|
|description||A string expression describing the type of file.|
|filter||A string expression specifying the filename extension.|
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. Don't 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.