Vcl.FileCtrl.TFilterComboBox.Filter

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

property Filter: string read FFilter write SetFilter stored IsFilterStored;

C++

__property System::UnicodeString Filter = {read=FFilter, write=SetFilter, stored=IsFilterStored};

Properties

Type Visibility Source Unit Parent
property published
Vcl.FileCtrl.pas
Vcl.FileCtrl.hpp
Vcl.FileCtrl TFilterComboBox

Description

Contains all the file masks displayed in the filter combo box.

Set the Filter property to specify the names that appear in the filter combo box, along with the masks associated with each name. Each mask is a file name that may include wildcards. The asterisk (*) is a wildcard which matches any number of arbitrary characters. The question mark (?) is a wildcard which matches a single arbitrary character. When the application runs, the file filter the user selects in the filter combo box becomes the value of the Mask property.

To create the value of Filter for a single file type, follow these steps:

1Type some meaningful text to indicate the type of file.

2Type a | character (vertical bar).

3Type the file filter.

Don't put in any spaces around the | character in the string.

Here's an example:



FilterComboBox1.Filter := 'Text files|*.TXT';



FilterComboBox1->Filter = "Text files|*.TXT";



If Filter is set to this string, the string "Text files" appears in the filter combo box. When the user selects "Text files", the mask is set to "*.TXT".

To specify multiple file filters, extend the value of Filter, separating each file name/mask combination with a | character. Filter can specify an any number of file filters, as long as the string is less than 255 characters.

Here's an example of two file filters that could be specified as the value of the Filter property:



'Text files (*.TXT)|*.TXT|Pascal files (*.PAS)|*.PAS'



"Text files (*.TXT)|*.TXT|C++ files (*.CPP)|*.CPP"



The previous example includes the file filters in parentheses in the text parts. This isn't required, but it's a common convention that helps users understand what to expect when they select a file filter.

The mask portion can include multiple file specifiers if they are separated with semicolons:



'All files|*.TXT;*.PAS;*.WB1'



"All files|*.TXT;*.CPP;*.RC"



See Also

Code Examples