From fa2005c7235379f710a85415a069af6552256775 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Wed, 9 Nov 2022 16:49:49 +0000 Subject: [PATCH] GridPrinter: Refine actions demo. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8598 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/gridprinter/examples/actions/main.lfm | 4 +++- components/gridprinter/examples/actions/main.pas | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/components/gridprinter/examples/actions/main.lfm b/components/gridprinter/examples/actions/main.lfm index 171fdbe1f..ba4b57568 100644 --- a/components/gridprinter/examples/actions/main.lfm +++ b/components/gridprinter/examples/actions/main.lfm @@ -3,10 +3,11 @@ object MainForm: TMainForm Height = 394 Top = 132 Width = 801 - Caption = 'MainForm' + Caption = 'GridPrinter Standard Actions Demo' ClientHeight = 374 ClientWidth = 801 Menu = MainMenu1 + OnCreate = FormCreate LCLVersion = '2.3.0.0' object StringGrid1: TStringGrid Left = 6 @@ -84,6 +85,7 @@ object MainForm: TMainForm Grid = StringGrid1 Footer.Font.Height = -11 Header.Font.Height = -11 + Header.Text = 'File "$FILENAME"||printed on $DATE' ShowPrintDialog = gpdPrintDialog Left = 334 Top = 135 diff --git a/components/gridprinter/examples/actions/main.pas b/components/gridprinter/examples/actions/main.pas index f30a9a1a3..6fda1c1b5 100644 --- a/components/gridprinter/examples/actions/main.pas +++ b/components/gridprinter/examples/actions/main.pas @@ -39,6 +39,7 @@ type ToolButton5: TToolButton; ToolButton6: TToolButton; procedure FileOpen1Accept(Sender: TObject); + procedure FormCreate(Sender: TObject); private public @@ -88,11 +89,18 @@ procedure TMainForm.FileOpen1Accept(Sender: TObject); begin // Load a csv data file StringGrid1.LoadFromCSVFile(FileOpen1.Dialog.FileName); + // Pass the name of the loaded file to the GridPrinter for the header. + GridPrinter1.FileName := FileOpen1.Dialog.FileName; // Adjust the grid column widths AutoAdjustColWidths(StringGrid1); // The grid was hidden after creation. It must be shown after loading data. StringGrid1.Show; end; +procedure TMainForm.FormCreate(Sender: TObject); +begin + DefaultFormatSettings.ShortDateFormat := 'yyyy-mm-dd'; +end; + end.