[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] |
Loads the grid content from the delimited values in AStream.
Source position: grids.pas line 1810
public procedure TCustomStringGrid.LoadFromCSVStream( |
AStream: TStream; |
ADelimiter: Char = ','; |
UseTitles: Boolean = True; |
FromLine: Integer = 0; |
SkipEmptyLines: Boolean = True |
); virtual; |
AStream |
|
Stream with the content loaded in the method. |
ADelimiter |
|
Delimiter between cell data in the stream; default is Comma (','). |
UseTitles |
|
Indicates if Column captions are loaded from values in the stream. |
FromLine |
|
Initial line number in the stream included in the grid content; default is 0. |
SkipEmptyLines |
|
Indicates if empty lines in the stream are ignored in the method. |
LoadFromCSVStream is a method used to load content in the grid from comma-separated values stored in the specified stream.
AStream is the TStream instance where the delimited values are stored.
ADelimiter is a character which identifies the delimiter used between column values on a row. Its default value is ',' (Comma) (decimal 44), but can be changed to another character value if needed.
Each row of values is terminated by a Carriage Return (Decimal 13) or Line Feed (Decimal 10) character. CR+LF may also be used. When LoadFromCSVStream encounters either of the characters, it is processed as an end-of-line marker.
UseTitles indicates whether the first row of values in the stream are treated as fixed column titles in the grid. When set to True, each column value is stored as the caption for the corresponding entry in the Columns collection (when enabled). If Columns are not used, the values are stored as Cell data in row number 0. When set to False, the first row is treated as cell data. The default value is True.
FromLine indicates the ordinal line number in AStream that is the first row loaded in the method. The default value is 0, and causes stream processing to begin at the first line. When a positive non-zero value is used, the lines are skipped by reading the corresponding number of end-of-line sequences from the stream.
SkipEmptyLines indicates whether blank lines are skipped when the row and column values are loaded in the method. The default value is True, and causes any row with a single empty column value to be skipped.
LoadFromCSVStream calls the LoadFromCSVStream routine in the LCSVUtils unit to load values from the stream. This routine provides support for converting character encodings when needed.
LoadFromCSVStream ensures that the grid control has enough columns to represent the values read for each record or row in the stream. When Columns is enabled (i. e. Columns.Count has a non-zero value), the Delete and Add methods in Columns are called to recreate column definitions for the number of delimited values read from the stream. If this occurs on the first line and UseTitles is enabled, each value in the row is stored as the Title for the corresponding TGridColumn instance in Columns. If Columns is not enabled, the value in ColCount is updated with the number of columns read from the stream and the values are stored in the first row (0) in the Cells property.
Please note that updates to the control occur in a BeginUpdate..EndUpdate block. This suppresses redrawing the control until all columns and rows in the stream have been loaded.
Use LoadFromCSVFile to load grid content from a file containing the comma-separated values.
Use SaveToCSVFile or SaveToCSVStream to store the content in the grid as comma-separated values.
|
Loads the grid from a file with delimited values for the columns and rows. |
|
|
Saves grid content as comma-separated values in the specified file name. |
|
|
Saves grid content as comma-separated values in the specified stream instance. |
|
|
Provides indexed access to a cell value by its column and row number. |
|
|
Definitions for the columns displayed the grid. |
|
|
Number of columns in the grid. |
|
|
Number of the fixed rows in the grid. |
|
|
Collection used to store column definitions for a grid control. |
|
|
Contains the attributes for the title in the fixed header for the column. |
|
Version 3.2 | Generated 2024-02-25 | Home |