GridPrinter: Refine actions demo.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8598 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2022-11-09 16:49:49 +00:00
parent 26fbe040da
commit fa2005c723
2 changed files with 11 additions and 1 deletions

View File

@ -3,10 +3,11 @@ object MainForm: TMainForm
Height = 394 Height = 394
Top = 132 Top = 132
Width = 801 Width = 801
Caption = 'MainForm' Caption = 'GridPrinter Standard Actions Demo'
ClientHeight = 374 ClientHeight = 374
ClientWidth = 801 ClientWidth = 801
Menu = MainMenu1 Menu = MainMenu1
OnCreate = FormCreate
LCLVersion = '2.3.0.0' LCLVersion = '2.3.0.0'
object StringGrid1: TStringGrid object StringGrid1: TStringGrid
Left = 6 Left = 6
@ -84,6 +85,7 @@ object MainForm: TMainForm
Grid = StringGrid1 Grid = StringGrid1
Footer.Font.Height = -11 Footer.Font.Height = -11
Header.Font.Height = -11 Header.Font.Height = -11
Header.Text = 'File "$FILENAME"||printed on $DATE'
ShowPrintDialog = gpdPrintDialog ShowPrintDialog = gpdPrintDialog
Left = 334 Left = 334
Top = 135 Top = 135

View File

@ -39,6 +39,7 @@ type
ToolButton5: TToolButton; ToolButton5: TToolButton;
ToolButton6: TToolButton; ToolButton6: TToolButton;
procedure FileOpen1Accept(Sender: TObject); procedure FileOpen1Accept(Sender: TObject);
procedure FormCreate(Sender: TObject);
private private
public public
@ -88,11 +89,18 @@ procedure TMainForm.FileOpen1Accept(Sender: TObject);
begin begin
// Load a csv data file // Load a csv data file
StringGrid1.LoadFromCSVFile(FileOpen1.Dialog.FileName); 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 // Adjust the grid column widths
AutoAdjustColWidths(StringGrid1); AutoAdjustColWidths(StringGrid1);
// The grid was hidden after creation. It must be shown after loading data. // The grid was hidden after creation. It must be shown after loading data.
StringGrid1.Show; StringGrid1.Show;
end; end;
procedure TMainForm.FormCreate(Sender: TObject);
begin
DefaultFormatSettings.ShortDateFormat := 'yyyy-mm-dd';
end;
end. end.