When I open a folder with an OpenDialog, how can I filter it so users can view only certain files (e.g., Stringgrid, *.sg) and the files with any other extension do not appear in the dialog window?
Delphi – How to show only certain file extensions in an open-file dialog
delphiopendialog
Best Answer
Set the
OpenDialog.Filter
property to the file filter you want.You can do this in the Object Inspector:
Filter
property, and you'll see a small button appear on the right edge with...
.On the left side is the description of the file (for instance,
Excel files (*.xls)
). The right side is the filter you want to use, as in*.xls
.You can also set it in code before displaying your dialog:
Of course, replace the Excel stuff with any description and mask you want to use.