Example 65 : Using TAdvGridCSVPager for using large CSV files with pagingTAdvGridCSVPager is a component that allows to work with CSV files in a paged way. That means that instead of loading the CSV file completely in the grid, you can browse & edit through the CSV file per page with a configurable page size. This offers a faster and less memory intensive solution to handle very large CSV files.
Using TAdvGridCSVPager is simple. It is a separate component that can be connected to the TAdvStringGrid (or descendent) component so when it is not used, it does not add any overhead to TAdvStringGrid. You can set the grid property for TAdvGridCSVPager component and use the TAdvGridCSVPager methods & properties to work with CSV files in pages.
Properties & methods in TAdvGridCSVPager:
Open Opens the CSV file set by the property FileName Close Closes the CSV file SavePage Saves the current viewed page in the grid to the CSV file First Show the first page of the CSV file in the grid Last Show the last page of the CSV file in the grid Next Show the next page of the CSV file in the grid Prev Show the previous page of the CSV file in the grid IsOpen: boolean Returns true when the AdvGridCSVPager has a CSV file opened FirstRow: integer Returns the row number in the CSV file of the first row displayed in the grid LastRow: integer Returns the row number in the CSV file of the last row displayed in the grid TotalRows: integer Returns the total number of rows in the CSV file Pages: integer Returns the total nr. of pages in the CSV file Page: integer Returns the page number of the current displayed page in the grid BOF: boolean Returns true when the first page of the CSV file is reached EOF: boolean Returns true when the last page of the CSV file is reached
The sample application shows how 4 buttons to browse through a CSV file are used. With a minimal amount of code, this simple paged CSV browser was created.
Delphi project & source files for downloading included in the main demos distribution for Delphi.