YOUSEFUL / DELPHI / COMPONENTS

TAtlasMemoryData

A data source that holds typed cells in memory, filled from invariant text or from typed cells.

Non-visual component Palette: Atlas Plot Unit Atlas.VGridData · Inherits TAtlasGridData · Product Atlas Virtual Grid

Description

Columns are added in code with a title, a TAtlasCellKind and an optional read-only flag. Nothing about them is stored in the .dfm. When the component is placed at design time and linked to a grid there, add the columns in code and then call the grid's ResetColumns. Rows are added whole from text with AddRow, and changed cell by cell with SetCell or SetText. The source itself enforces column kinds and read-only columns, so they hold for code as well as for the grid. Every change notifies the watching grids; wrap bulk loads in BeginUpdate/EndUpdate so they react once. Each cell is one TAtlasCell record.

Members

MemberKindWhat it does
CreateconstructorCreates an empty source with no columns and no rows.
DestroydestructorFrees the cells.
AddColumnmethodAdds a column and returns its index.
AddRowmethodAdds a row from one text per column and returns its index.
DeleteRowmethodRemoves a row; later rows move up.
ClearRowsmethodRemoves every row and keeps the columns.
ClearAllmethodRemoves every row and column.
ColumnTitlemethodThe title given to AddColumn.
ColumnKindmethodThe kind given to AddColumn.
ColumnReadOnlymethodThe read-only flag given to AddColumn.
GetCellmethodThe stored cell.
SetCellmethodStores a cell of the column's kind; a null of that kind blanks it.
BeginUpdatemethod from TAtlasGridDataStarts a batch: the changes made until the matching EndUpdate reach watching grids as one notification.
EndUpdatemethod from TAtlasGridDataEnds a batch.
AddListenermethod from TAtlasGridDataRegisters a method that is called, with the source as Sender, after every change or batch.
RemoveListenermethod from TAtlasGridDataUnregisters a method.
SetTextmethod from TAtlasGridDataParses Text for the column's kind with Settings (see TAtlasCell.TryParse) and stores the result with SetCell.
CheckCellmethod from TAtlasGridDataRaises EAtlasGridError Column n does not exist or Row n does not exist unless the cell lies inside the data.
RowCountproperty from TAtlasGridDataNumber of rows.
ColumnCountproperty from TAtlasGridDataNumber of columns.
Versionproperty from TAtlasGridDataIncreases on every change, including each change inside a batch and once more when the batch ends.

Constructors

Create constructor

constructor Create(AOwner: TComponent); override;

Creates an empty source with no columns and no rows.

Destructors

Destroy destructor

destructor Destroy; override;

Frees the cells. Grids bound to the source unbind themselves.

Properties

RowCount propertyinherited from TAtlasGridData

property RowCount: Integer read GetRowCount;

Number of rows.

ColumnCount propertyinherited from TAtlasGridData

property ColumnCount: Integer read GetColumnCount;

Number of columns.

Version propertyinherited from TAtlasGridData

property Version: Integer read FVersion;

Increases on every change, including each change inside a batch and once more when the batch ends. Compare two readings to tell whether anything changed.

Methods

AddColumn method

function AddColumn(const Title: string; Kind: TAtlasCellKind = ckText; ReadOnly: Boolean = False): Integer;

Adds a column and returns its index. Existing rows get a null cell in it. A ReadOnly column refuses SetCell and SetText, from code as well as from the grid; fill it through AddRow. A grid that is already bound does not add a column for it by itself: call its ResetColumns or add a grid column.

pascal
Orders.AddColumn('Order', ckNumber, True);

AddRow method

function AddRow(const Values: array of string): Integer;

Adds a row from one text per column and returns its index. Values are read with invariant settings: . as the decimal separator, ISO 8601 dates such as 2026-03-31 or 2026-03-31T14:30:00 (or invariant MM/dd/yyyy), and yes/no, true/false, y/n or 1/0 in any case. Empty text is null. The row is added whole or not at all. A wrong number of values raises A row needs n values; m given, and a value that does not fit raises "x" does not fit column "Title"; both are EAtlasGridError. Read-only columns can be filled this way.

pascal
Orders.AddRow(['Contoso', '1250.50', '2026-03-31', 'no']);

DeleteRow method

procedure DeleteRow(Row: Integer);

Removes a row; later rows move up. Raises EAtlasGridError for a row that does not exist.

ClearRows method

procedure ClearRows;

Removes every row and keeps the columns. Sends no notification when there were no rows.

ClearAll method

procedure ClearAll;

Removes every row and column. Bound grids keep their own columns; call ResetColumns on them after adding the new columns.

ColumnTitle method

function ColumnTitle(Column: Integer): string; override;

The title given to AddColumn. An index outside the columns raises the list's EArgumentOutOfRangeException.

ColumnKind method

function ColumnKind(Column: Integer): TAtlasCellKind; override;

The kind given to AddColumn.

ColumnReadOnly method

function ColumnReadOnly(Column: Integer): Boolean; override;

The read-only flag given to AddColumn.

GetCell method

function GetCell(Column, Row: Integer): TAtlasCell; override;

The stored cell. Raises EAtlasGridError outside the data.

pascal
Missing := Orders.GetCell(1, 0).IsNull;

SetCell method

procedure SetCell(Column, Row: Integer; const Cell: TAtlasCell); override;

Stores a cell of the column's kind; a null of that kind blanks it. Raises EAtlasGridError outside the data, for a read-only column (Column "Title" is read-only) and for a cell of another kind (Column "Title" holds another kind of value).

pascal
Orders.SetCell(1, 0, TAtlasCell.OfNumber(1300.75));

BeginUpdate methodinherited from TAtlasGridData

procedure BeginUpdate;

Starts a batch: the changes made until the matching EndUpdate reach watching grids as one notification. Batches nest.

pascal
Orders.BeginUpdate;

EndUpdate methodinherited from TAtlasGridData

procedure EndUpdate;

Ends a batch. When the outermost batch ends and something changed, the listeners are called once. An EndUpdate without a BeginUpdate is ignored.

pascal
Orders.EndUpdate;

AddListener methodinherited from TAtlasGridData

procedure AddListener(const Listener: TNotifyEvent);

Registers a method that is called, with the source as Sender, after every change or batch. Adding the same method twice registers it once. Grids register themselves when bound, so this is for your own code.

RemoveListener methodinherited from TAtlasGridData

procedure RemoveListener(const Listener: TNotifyEvent);

Unregisters a method. Safe during a notification and after the source has begun to be destroyed.

SetText methodinherited from TAtlasGridData

procedure SetText(Column, Row: Integer; const Text: string; const Settings: TFormatSettings);

Parses Text for the column's kind with Settings (see TAtlasCell.TryParse) and stores the result with SetCell. Raises EAtlasGridError for a cell outside the data and for text that does not parse ("abc" is not a number, is not a date, is not yes or no); the stored value is unchanged. The grid's editor and Delete key write through this method with the global FormatSettings.

pascal
Orders.SetText(1, 0, '1300.75', TFormatSettings.Invariant);

CheckCell methodinherited from TAtlasGridData

procedure CheckCell(Column, Row: Integer);

Raises EAtlasGridError Column n does not exist or Row n does not exist unless the cell lies inside the data.

Examples

Fill a memory source

Four typed columns and three rows, loaded in one batch. The third row's amount, date and paid flag are null.

pascal
uses Atlas.VGridData;

procedure FillOrders(Orders: TAtlasMemoryData);
begin
  Orders.AddColumn('Customer');
  Orders.AddColumn('Amount', ckNumber);
  Orders.AddColumn('Due', ckDateTime);
  Orders.AddColumn('Paid', ckBoolean);
  Orders.BeginUpdate;                        // one notification for the whole batch
  try
    // One text per column, read with invariant settings: '.' decimals, ISO dates.
    Orders.AddRow(['Contoso', '1250.50', '2026-03-31', 'no']);
    Orders.AddRow(['Fabrikam', '980', '2026-02-28', 'yes']);
    Orders.AddRow(['Northwind', '', '', '']);   // empty text is a null cell
  finally
    Orders.EndUpdate;
  end;
end;

Bind it to a grid

The grid creates one column per data column when it has none. See the quick start sample for sorting, filtering, totals and export.

pascal
uses Vcl.Forms, Vcl.Controls, Atlas.VGridData, Atlas.VGrid;

procedure ShowOrders(Form: TForm; Orders: TAtlasMemoryData);
var Grid: TAtlasVirtualGrid;
begin
  Grid := TAtlasVirtualGrid.Create(Form);
  Grid.Parent := Form;
  Grid.Align := alClient;
  Grid.Data := Orders;                       // no columns yet: one per data column
  Grid.FrozenColumns := 1;                   // Customer stays put when scrolling sideways
  Grid.Columns[1].Format := '#,##0.00';
  Grid.Columns[1].Total := tkSum;
  Grid.Columns[2].Format := 'yyyy-mm-dd';
  Grid.Sort(1, True);                        // largest amount first
end;

TAtlasVirtualGrid · TAtlasGridData · TAtlasCell · TAtlasCellKind · TAtlasVirtualData

Also in Atlas Virtual Grid

TAtlasVirtualGrid · TAtlasVirtualData · TAtlasPlotData