Using the Tables

The table component which is available on each tab of the Chartbook is a component which can be used to display text in tabular form.

The table on a particular tab can be accessed via the array property ChartBook.Tables[idx] and its subproperties (with idx as the tab number). Its layout can be configured by the method Configure.

The number of visible rows and columns is determined by the properties NrOfRows and NrOfColumns. In addition to the visible cells, each row has one invisible cell (column index 0) which can be used to store additional hidden information in the table. The cells of the table can be accessed via the property Elem. Numeric strings can be read by using the readonly property AsNumber.

The headers of the columns can be adjusted by using the property Header. The methods AddRow and RemoveRow can be used to add an additional empty row to the end of the table and to remove a particular row from the table. By default, all cells of the table are read-only. However, the table can be switched columnwise into an editable mode by setting the array property ColumnEditable.

Before storing more than a few strings, it is recommended to set the property SuppressPaint to TRUE in order to prevent repeated repaint events. Otherwise, loading the table will be extremely slow.

The rows of the table may be sorted according to any column (including the hidden column 0) by using the method Sort. The method UnSort re-establishes the original order of the rows. Rows may also be sorted interactively by clicking on the corresponding header field if the property SortEnabled is set TRUE.

The visual appearance can be adjusted by the color properties ColorText, ColorBkgdNormal, and ColorBkgdShaded. The property RowColPattern determines the pattern of shaded and normal rows. Note that there are some additional parameters covered by the property Options which may also affect the visual appearance of the table. Any column of the table may also be set up as a checked column (strings with a check box or a radio button left to it) by setting the property ColumnCheckMode accordingly. The check boxes may be ticked off either by clicking them or programmatically by using the property ElemChecked.

The rows of the table can be disabled on an individual basis by using the array property RowEnabled. Disabled rows are displayed in different colors (ColorDisabledText, ColorDisabledBkgd) and cannot be edited by the inplace editor, nor can any associated check boxes be ticked off.

Sample
program:
The following program configures the table of tabsheet 1 to consist of 5 columns and 20 rows. All cells are filled with their cell address. The cells in column two can be ticked off. Finally the columns are resized to display all cells optimally.
program ShowTableOnly;

const
  PAGE = 1;

var
  i, j : integer;

begin
ChartBook.Reset;
ChartBook.TabCaption[PAGE] := 'Tab 1';
ChartBook.Configure
   (PAGE,               // page 1
    false, true, false, // only the table is visible
    250, 250);          // default width & height

with ChartBook.Tables[PAGE] do
  begin
  Clear;
  NrOfRows := 20;
  NrOfColumns := 5;
  SuppressPaint := true;
  for i:=1 to NrOfColumns do
    begin
    Header[i] := 'Col-'+IntToStr(i);
    for j:=1 to NrOfRows do
      Elem[i,j] := 'Cell ['+IntToStr(i)+','+IntToStr(j)+']';
    end;
  ColumnCheckMode[2] := cmBox;
  FitAllColWidths (NrOfColumns, true, 4, 200, 24);
  SuppressPaint := false;
  end;
end.