SaveDialog.Filter does not change the file's extension.
Original Reporter info from Mantis: crlab @neurolabusc1
-
Reporter name: Chris Rorden
Original Reporter info from Mantis: crlab @neurolabusc1
- Reporter name: Chris Rorden
Description:
With Delphi, you can use the SaveDialog.Filter to allow the user to select different formats for the file - and the returned filename includes the selected extension in the filename. Lazarus correctly shows the available filetypes, but selecting between filetypes does not change the file's extension...
Create a form with a TButton (Button1) and TSaveDialog (SaveDialog1). Set the event for pressing Button1 to the code below. When you run the software and press the Button, you can name a new file - however, changing the 'Save as filetype' pulldown to .csv does not change the filename - the only way to change the output to .csv is to explicitly add .csv to the filename.
procedure TForm1.Button1Click(Sender: TObject);
begin
SaveDialog1.Filter := 'Text|*.txt|CommaSeparatedValues (*.csv)|*.csv';
SaveDialog1.DefaultExt := '.txt';
if not SaveDialog1.Execute then exit;
showmessage(SaveDialog1.Filename);
end;
Mantis conversion info:
- Mantis ID: 7797
- Version: 0.9.21 (SVN)
- Fixed in version: 0.9.31 (SVN)
- Fixed in revision: 31597 (#e121294b)
- Monitored by: » Frederick (Frederick), » @flyingsheep (Bart Broersma)
- Target version: 1.0.0
- LazTarget: 1.0