opendialog Filter property
Return to Introduction  Previous page  Next page
Applies to
dcOpenDialog and dcSaveDialog components.  

Declaration
property Filter: String;  

Description
The Filter property determines the file masks (filters) available in the dialog. The file-selection dialog includes a drop-down list of file types under the edit box. When the user picks a file type from the list, only files of the selected type are displayed in the dialog.  
 
To configure file masks at design time, click on the ellipsis marks (...) to the right of the Filter property in the Object Inspector. This opens the Filter editor. In the left column of the Filter editor, under Filter Name, type a brief description of each file type that will be available at runtime. In the right column, under Filter, type the file mask corresponding to each description. For example, the description "Text files" might appear to the left of the mask "*.TXT", and the description "Pascal source files" might appear to the left of the mask "*.PAS". Since the description appears in the drop-down list at runtime, it is often helpful to show the mask explicitly in the description (for example, "Text files (*.txt)").  
 
To create file masks in program code, assign a value to the Filter property that consists of a description and a mask separated by a vertical bar (pipe) character. Do not include spaces around the vertical bar. For example,  
 
dcOpenDialog1.Filter := 'Text files (*.txt)|*.TXT';  
 
Multiple filters should be separated by vertical bars. For example,  
 
dcOpenDialog1.Filter := 'Text files (*.txt)|*.TXT|Pascal files (*.pas)|*.PAS';  
 
To include multiple masks in a single filter, separate the masks with semicolons. This works both in the Object Inspector and in program code. For example,  
 
dcOpenDialog1.Filter := 'Pascal files|*.PAS;*.DPK;*.DPR';  
 
If no value is assigned to Filter, the dialog displays all file types.  

See also
FilterIndex property.