SaveDialog suggested filenames to match extension filter

506 views Asked by At

When my program displays a SaveDialog to save a file I can use the Filter and Filter Index properties to restrict the files displayed to certain extensions. Also, when I set the DefaultExt property then, as the user types a filename, matching files in the folder are displayed as suggestions in a dropdown box and one can be selected with the mouse. For example if the filter is set to "*.xml" then only filenames matching that extension appear in the the dialog list of files. But if the user type "Test", then you will get a dropdown list of suggestion files like: TestA.doc TestB.xml Test123.pdf TestX.xml (if those files are present in the folder)

But I would like the suggestion list to only contain the files that match the filter, such as *.xml. Is that possible? The problem is that users can hit the wrong suggestion and save their file with the wrong extension.

1

There are 1 answers

0
Mojtaba Tajik On

TSaveDialog internally uses the IFileDialog interface of Windows. That interface doesn't offer any way in which to change how to filter files in suggestion dropdown text box of File Name field.

You can :

  • Implement own dialog from scratch
  • Use component like DexExpress which is not free
  • Check result of save dialog after execution of it and validate the user selection file and show proper message to user if the file is not valid