[fpc-pascal] How to use fpGUI?

Graeme Geldenhuys mailinglists at geldenhuys.co.uk
Sun Jul 27 01:45:05 CEST 2014


On 2014-07-21 07:10, Nataraj S Narayan wrote:
> Does the latest fpgui have TFpgStringGrid  have the method
> 'LoadFromCSVFile' as in lcl TStringGrid?

It didn't, but does now. :)  Get the latest code from the 'develop' branch.

I didn't like the idea of including hard-coded CSV methods and CSV
processing into the standard StringGrid component, so for fpGUI I
created a StringGridBuilder class that does that for you. This way the
builder class can be extended (new methods added to the original), or a
descendant class created and key methods overridden so it can handle
other file formats too. For example fixed length or TAB delimited files,
or even an ODS (OpenDocument Spreadsheet) file.

Usage:
======

uses
  fpg_StringGridBuilder;

...

var
  sgb: TStringGridBuilder;
begin
  try
    sgb := TStringGridBuilder.CreateCustom(Grid1, edtFile.FileName,
chkHasHeader.Checked);
    sgb.Run;
  finally
    sgb.Free;
  end;
end;


This is actually similar to what I have done in one of my commercial
applications. But instead of a CSV file, the columns (including title &
width) and sort order was driven by a set of "View" classes. You could
have multiple views of the same data objects, by simply selecting the
desired view from a menu. The StringGridBuilder then handled the whole
setup and grid population for you.


Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/



More information about the fpc-pascal mailing list