TAdvGridPrintSettingsDialog Setup IniFile

I am creating a program with C++Builder 6

Using TMS Component Pack ver last version available for C++Builder6

Using TAdvStringGrid with TAdvGridPrintSettingsDialog & TAdvPreviewDialog

For TAdvGridPrintSettingsDialog I have set up a IniFile to save & load the settings.

I have set up a button to preview and when selecting Preview I then have to go to the Preferences Tab and click on Load Settings to format the preview screen as previously designed and saved to disk.

Question: Is there a way to dynamically read the Ini file from disk and automatically load the Setup Preferences when the user selects to preview the Grid data?

I'm not 100% sure I understand what you need.

With grid.LoadPrintSettings(), grid.SavePrintSettings() you can programmatically save & load print settings, so you could load specific settings before you launch the TAdvGridPrintSettingsDialog

While I am in the TAdvGridPrintSettingsDialog I have set up the header, footer and applicable fonts for the display and save them to disk to a file AdvGridPreviewSettings.ini in the local (executable) folder.

// Following your instructions I first initialize the iniFile Name:

String iniFile=DM->GetExePath()+"AdvGridPreviewSettings.ini";

// Then I call the advgrid LoadPrintSettings function:


// then call advgrid print settings dialog


// after closing I then call the preview dialog:


However the loaded print settings do not take effect,

Is there something else I need to do?

Can you please verify by testing the values of PrintSettings.Font, PrintSettings.HeaderFont, PrintSettings.FooterFont that the values were properly loaded from the INI file.
Can you also verify by inspecting the INI file that it effectively contains the expected values?

When the INI file contains the settings and the path to the INI file is correct, loading the print settings should work without issues.

On a test run I set up the AdvGrid Print Settings for Border, BorderStyle, Fit to Page, Table Font, Fixed Font, Header Font, Footer Font, DatePosition, Time Position, Title Position, Title Text, Page Numbers->Pages Position, Page Numbers->Prefix.

I made sure I properly coded to load the ini file

    // set component ini file

    String iniFile=GetExePath()+"AdvGridPreviewSettings.ini";

    asg->LoadPrintSettings(iniFile,iniFile); <- why does it require 2 file names?

Ran with debugger and the print settings were not what I set up nor what the "INI" file specified.

LoadPrintSettings does not require 2 filenames. The first parameter is the filename and the 2nd parameter is the section within that filename.

I have retested this here and I cannot see any problem.

You can download this test project via:

Bruno Fierens2017-04-26 11:38:59

Change my platform RAD Studio 10.1 Berlin: - OS Win 7 Professional

I took your Delphi Example and ran it in Delphi as is. Prior to running the program I looked at your saved INI file (gridprintsettings.ini) and Internally the file contained only one header : [print].

I ran the program and made changes to the Print Settings, Closed up the program and re-ran it.

Clicked on the Load Settings button and then clicked on Show Settings button, however none of the changes I made were there.

Again looking at the INI file I noticed it now contained two sections: [print] and [printsettings]

Going back into the code I changed the load file from




I then ran the program and clicked on the button Load Settings and then clicked Show Settings. The settings I made were now there but I noticed on the (Tab: Margins) was reset back to mm instead of inches that I had set, otherwise everything I set was now formatting the preview screen .

I then added code to the form constructer to dynamically load the INI file on start up- ran the program, clicked Show Settings and all formatting was there as I set up previously.

Following this I created the same program in C++Builder and it worked as I expected.

I want to thank you in leading me to understanding how to load and setup my preview form.

I have some questions:

1: which .pdf Guide describes the above print preview settings and how to use the advstringgrid1.LoadPrintSettings ?

2: Why when I looked at your INI file it contained one section [print] and when I made changes and saved them back to the original INI file it then contained two sections with the addition of [printsettings]?

  1. Looks like this wasn't added to http://www.tmssoftware.biz/download/manuals/TMS%20TAdvStringGrid%20Developers%20Guide.pdf yet. We'll look to update this.

    2. When there was already a 'print' section and you change the section to 'printsettings' this won't affect the existing section in the INI file.