Sei sulla pagina 1di 141

Library of Components EhLib

Developers guide

EhLib Team
Edition: 2.00
(Changes compared to
revision 1.62 is highlighted in
red)

Contents

Introduction ............................................................................................................... 5
Installation ............................................................................................................... 10
Unpacking archive......................................................................................................................10
Installing packages. ....................................................................................................................10
Installing help files. ....................................................................................................................12

Using TDBGridEh component ................................................................................ 13


Brief description of TDBGridEh, TDataLink and TDataSet. ....................................................13
Working with TDBGridEh at design-time. ................................................................................13
Types of columns and data types in columns .............................................................................14
Enable / Disable editing data in the Grid ...................................................................................22
The control data input in the InplaceEditor ................................................................................23
Moving and resizing columns in the grid. ..................................................................................23
Visibility columns in the grid .....................................................................................................24
Fonts and coloring of the data grid.............................................................................................25
The properties for formatting the data in the grid ......................................................................26
Data row height. .........................................................................................................................28
Events and properties to control the reaction of the mouse. ......................................................29
Events and properties to control the reaction of the keyboard. ..................................................30
Panel of detail information for record RowDetailPanel. .........................................................32
RowPanel mode..........................................................................................................................33
Working with datain grouping mode. ........................................................................................34
Display graphic in grid background. ..........................................................................................42
Searching Data in the Grid. ........................................................................................................43
Search panel and filter data. .......................................................................................................44
TDBGridEh and vertical scrollbar. ............................................................................................46
Customizing scrollbars. ..............................................................................................................46
Extra horizontal scroll bar slider (ScrollBar). ............................................................................47
Flexible adjustment of color and the presence of the border of the client area Grid. ................49
New event TColumnEh.OnGetHideDuplicatesValue to indicate accurately when to hide
duplicate values. .........................................................................................................................49
Filtering data in drop-down lookup lists when typing. .............................................................. 50
Using DBGridEh for sorting and filtering data in the DataSet. .................................................51
Adjusting grid for sorting data: ..................................................................................................52
Adjusting grid for filtering data: ................................................................................................ 52
Customizing grid title. ................................................................................................................54
Customizing Indicator column. ..................................................................................................56
Customizing grid footer. ............................................................................................................57
Hints and Tooltips ......................................................................................................................59
Drawing information about the absence of records in a dataset. ...............................................61
Setting the display of tree records .............................................................................................. 61
Import/Export TDBGridEh data to/from various formats..........................................................62
Using the drop-down menu PopupMenu ...................................................................................63
Using properties of TDBGridEh.IndicatorTitle. ........................................................................64
Using global properties for TDBGridEh. ...................................................................................65
Other features. ............................................................................................................................68
Other features and events of the component ..............................................................................71
Access to protected class methods .............................................................................................74
Converting existing TDBGrid component to TDBGridEh. .......................................................75

Using TPrintDBGridEh component ........................................................................ 76


Rich text before and after grid....................................................................................................76
Padding margins .........................................................................................................................77

Page header and footer. ..............................................................................................................77


Selecting print page orientation..................................................................................................77
Other events and a property of TPrintDBGridEh.......................................................................77
Features that current version of TPrintDBGridEh is not supported. ..........................................78

Using TDBVertGridEh component......................................................................... 79


Column header fields .................................................................................................................80
String types and data types in the data lines...............................................................................80
Grouping rows by Category .......................................................................................................81
Sort by column header row. .......................................................................................................82
Multiple choice and work with the clipboard.............................................................................82
Set fonts and coloring grid cells using events ............................................................................83
Unload the contents of the components in TDBVertGridEh Xlsx file ......................................84
Other features and events of the component ..............................................................................85
Working with TDBVertGridEh component at Design-Time .....................................................86
A class for setting the global behavior of all the elements and TDBVertGridEh TDBGridEh
project .........................................................................................................................................86

Using TDBSumList component .............................................................................. 88


Common understanding of TDBSumList. .................................................................................88
How it works and why SumList sometimes calculate aggregation values incorrectly. .............88

Using data-aware edit controls ................................................................................ 89


Common understanding of edit controls. ...................................................................................89
Dynamics properties in components - DynProps. ......................................................................90
Working with edit buttons ..........................................................................................................91
Working with lists MRUList (last entry list) .............................................................................93
ControlLabel - signature for the "control" data editing .............................................................. 93
Using TDBDateTimeEditEh control. .........................................................................................95
Using TDBNumberEditEh control. ............................................................................................95
Using TDBComboBoxEh control. .............................................................................................95
TDBMemoEh control .................................................................................................................96
TDBImageEh control .................................................................................................................96
TDBRadioGroupEh control .......................................................................................................96
TDBRichEditEh control .............................................................................................................97
Using TDBLookupComboboxEh control. .................................................................................97
Using SpecRow in columns of DBGridEh component and in DBLookupComboBoxEh
component. .................................................................................................................................98

DropDownForms - custom drop-down windows.................................................... 99


View properties of components at Run-Time ....................................................... 105
Using TPropStorageEh and TPropStorageManagerEh components .................... 106
Introduction in technology of interaction between MemTable and DataDriver. .. 107
TMemTableEh component.................................................................................... 108
Two working mode of TMemTableEh component. .................................................................108
ViewScroll ................................................................................................................................ 108
Master/detail relations. .............................................................................................................108
Working with AutoIncrement fields ........................................................................................109
Using indexes. ..........................................................................................................................109
Using shared array of records by several TMemTableEhs. ....................................................109
Moving records in TMemTableEh when dghRecordMoving mode is active. .........................109
TRefObjectField field type.......................................................................................................109
Using maintained aggregates ...................................................................................................110
Records sorting. ........................................................................................................................110
Creation/removing table data in memory in the stand-alone mode. ......................................110

Working with MemTableEh in the 'with datadriver' mode. .....................................................111


Cached updates. ........................................................................................................................111
Marking and Returning to Records. .........................................................................................112
Searching in TMemTableEh ....................................................................................................112
Quick access to the record values. ...........................................................................................114
Changes in the structure of the internal array of MemTableEh without losing data. ..............117
Save / load data from / to the file (s). .......................................................................................117
Internal objects of TMemTableEh component.........................................................................118
Storing records in tree mode (TreeView). ................................................................................118
Workig with TMemTableEh at design-time. ...........................................................................122

TDataDriverEh component. .................................................................................. 122


TSQLDataDriverEh component............................................................................ 124
TSQLDataDriverEh or TXXXDataDriverEh, which one is best to use. ............................... 126
Working with TSQLDataDriverEh and TXXXDataDriverEh at design-time. ......................127
Uisng Connection Provider. .....................................................................................................127
Macro variables in SQL expressions SQLDataDriverEh.XXXCommand. ............................. 128
Special macro variables. ...........................................................................................................129

Components for consolidated data analysis .......................................................... 132


Description of components of data analysis. ............................................................................132
Indicator data generation TPivotGridEh with the possibility of interrupting the process .......133

Components for planning and visual interactive event management ................... 134
Components for uploading DataSet to a text file and load a text file ................... 137
Hiding a component form in Design-Time ........................................................... 140
Feedbacks and bug reports .................................................................................... 141

Introduction
The Library contains components and classes for Borland Delphi and Borland C++ Builder. The
Library is intended to write professional interactive applications that work with the database:
rendering, printing and entering data by the end user.
TDBGridEh component
Using TDBGridEh
It provides all functionality of TDBGrid and adds several new features as follows:
- Allows to select records, columns and rectangle areas.
- Provides special titles that can cover several or all columns.
- Can have a footer that is able to show sum/count/other field values.
- Allows to resize column automatically to fit grid width equal to client width.
- Has an ability to change row height and title height.
- Allows automatic broken of a single line long title and data rows to a multiline.
- Allows title to act as button and, optionally show a sort marker.
- Allows to mark titles by sortmarking sings automatically and sort data in DataSet.
- Allows to truncate long text with ellipsis in cells.
- Allows lookup list to show several fields.
- Have an ability to make an incremental search in lookup fields.
- Can have frozen nonscrollable columns.
- Allows to show DateTime picker for TDateField and TDateTimeField.
- Allows to show bitmaps from TImageList depending on field value.
- Allows to hide and track horizontal or vertical scrollbars.
- Allows to hide columns.
- Allows to show 3D frame for frozen, footer and data rows.
- Allows to draw memo fields.
- Can show multiline inplace editor.
- Can have a proportional scrolling for DadaSets independently of datasets sequencing.
- Allows to show checkboxes automatically for Boolean fields. Allows to show checkboxes
for other type of fields.
- Has procedures to save and restore layout (visible columns, columns order, columns
width, sortmarkers, row height) in/from registry or ini file.
- Allows to show hint (ToolTips) for text that don't fit in the cell.
- Allows to export data to Text, Csv, HTML, RTF, XLS and internal formats.
- Allows to import data from Text and internal formats.
- Can sort data in various datasets.
- Can filter data in various datasets.
TDBVertGridEh
Using TDBVertGridEh
TDBVertGridEh Component is a Vertical Grid. The component is used to display and edit a single
record DataSet in a vertical orientation. The data is displayed in two columns. The first column
displays the names of the fields in the second field values of the current record.
The component supports the following features:
- Allows you to display Memo field of graphics and pictures Blob fields.
- Allows you to wrap long lines and increase the height of each cell to display all the
contents of the cell.
- Allows the user to customize the mapping of cell data.
- Has the event to dynamically change the font, color and other parameters of the cell,
depending on the values of the fields of the current record.

- Allows you to display special tips Tooltips for text that does not fit into the cell.
- Allows you to have a dynamic line - created according to the dataset fields, and static created and customized in advance DesignTime. It works the same in columns Columns
TDBGridEh.
See a detailed description of the component in the section Using TDBVertGridEh
TDBLookupComboboxEh component
Using edit controls
It provides all functionality of TDBLookupCombobox and adds several new features as follows:
- Can have flat style.
- Allows to assign values as to KeyValue property and as to display Text property.
- Allows to hold KeyValue and Text that will not affect to each others values.
Drop down list can:
- Show titles,
- Have sizing grip,
- Automatically set width as sum of DisplayWidth of the list fields (Width = -1),
- Automatically drops when the user pressed the key.
- Can have specified width.
Edit button can:
- Show DropDown and Ellipsis or Bitmap image.
Have additional events: OnKeyValueChanged and OnButtonClick.
TDBSumList component
Using TDBSumList
It is intended for calculating sums and amount of records in a TDataSet with dynamic changes.
Component keeps a list of TDBSum objects, which contains types of group operations (goSum
or goCount) and name of fields which values need some calculation. (goCount name of field is
unnecessary).
TPrintDBGridEh component
Using TPrintDBGridEh
TPrintDBGridEh provides properties and routines for preview and print of TDBGridEh
component with several features:
- Ability to expand rows vertically until all text is printed.
- Ability to scale grid to fit it to the page width.
- Ability to print/preview title for grid.
- Ability to print/preview page header and page footer where you can specify macros for
current page, current date, current time and/or static text.
- Automatically print/preview multi-selected area of TDBGridEh if its area is not empty.
- Ability to print/preview rich text before and after grid.
TPreviewBox component
TPreviewBox lets you to create a customizable runtime preview.
TPrinterPreview object
TPrinterPreview lets you to record printable data in buffer for following output them on screen
and to printer. TPrinterPreview have all functions and properties as in TPrinter object. You can
use TPrinterPreview object similarly to TPrinter except some details. In TPrinter
Printer.Canvas.Handle and Printer.Handle is the same but in TPrinterPreview

PrinterPreview.Canvas.Handle represents the metafile in that is recored the data and


PrinterPreview.Handle represents Printer.Handle. It means that you have to use
PrinterPreview.Canvas.Handle for drawing operation (like DrawText, DrawTexteEx, e.t.c.) and
use PrinterPreview.Handle for such functions as returning information about printer facilities
(GetDeviceCaps, e.t.c.). Global function PrinterPreview returns default PrinterPreview object
and shows data in the default preview form.
TDBEditEh component
Using edit controls
represents a single or multi-line edit control that can display and edit data of field in a dataset
or can work as non data-aware edit control.
TDBDateTimeEditEh component
Using edit controls
represents a single-line date or time edit control that can display and edit data of TDateTime
fields in dataset or can work as a non data-aware edit control.
TDBComboBoxEh component
Using edit controls
represents a single or multi-line edit control that combines an edit box with a scrollable list and
can display and edit a field in a dataset or can works as non data-aware combo edit control.
TDBNumberEditEh component
Using edit controls
represents a single-line number edit control that can display and edit a numeric field in a
dataset or can work as non data-aware edit control.

TDBMemoEh
The component is designed for editing multi-line text data.
The component can operate in Data-Aware mode (connected to DataSet), and can work as non
data-aware edit control.
TDBImageEh
The component is designed for editing a graphic data.
The component can operate in Data-Aware mode (connected to DataSet), and can work as non
data-aware edit control.
TDBRadioGroupEh
The component is a set of selection flags (radiobuttons).
The component can operate in Data-Aware mode (connected to DataSet), and can work as non
data-aware edit control.
TDBRichEditEh
The component is designed for editing multi-line text data with the ability to format it as
RichText.
The component can operate in Data-Aware mode (connected to DataSet), and can work as non
data-aware edit control.

TPropStorageEh, TIniPropStorageManEh, TRegPropStorageManEh components


Using
TPropStorageEh
These components realize a technology of storing component properties to/from such storages
as INI files, Registry etc.
TMemTableEh component
It is a dataset that holds all data in memory and can get data from TDataDriverEh and return
changed records back to the TDataDriverEh.
TDataDriverEh component
Deliver records from the server to the TMemTableEh.
Deliver changed records from TMemTableEh back to the server.
TDataSetDriverEh component
It is a DataDriver that deliver records in TMemTableEh from other DataSet and deliver changed
records from TMemTableEh back to the DataSet.
TSQLDataDriverEh component
It is a DataDriver that have properties for keeping five SQL expressions and parameters for
querying data, removing, insertions, updating and refreshing records. TSQLDataDriverEh by
itself cant request data from server, but it can prepare parameters of the request and have a
global event that programmer can write for transferring SQL expression to/from the server.
TBDEDataDriverEh component
It is a DataDriver that interacts with the DB server using BDE connection.
TIBXDataDriverEh component
It is a DataDriver that interacts with the DB server using IBX connection.
TDBXDataDriverEh component
It is a DataDriver that interacts with the DB server using DBX connection.
TADODataDriverEh component
It is a DataDriver that interacts with the DB server using ADO connection.
TADOConnectionProviderEh component
Provides the interface between the component TADODataDriver and TADOConnection in
Design-Time and Run-Time. Contains abuilt TADOConnection component. Specifies the type of
server data for the correct operation of additional server operations, such as getting the value
of the incremental table fields after inserting record, etc.
TDBXConnectionProviderEh component
Provides the interface between TDBXDataDriver and TSQLConnection in Design-Time and RunTime. Contains embedded TSQLConnection component. Specifies the type of server data for

the correct operation of additional server operations, such as getting the value of the
incremental table fields after inserting record, etc.

TIBXConnectionProviderEh component
Provides the interface between the component TIBXDataDriver and TIBDatabase in DesignTime and Run-Time. Contains built TIBDatabase component.
TBDEConnectionProviderEh component
Provides the interface between the component TBDEDataDriver and TDatabase in Design-Time
and Run-Time. Contains built TDatabase component. Specifies the type of server data for the
correct operation of additional server operations, such as getting the value of the incremental
table fields after inserting record, etc.

TPivotDataSourceEh
Downloads and store pivot data.
TPivotGridEh
Component-control to display pivot data.
TPivotGridToolBoxEh
Component-control for configuration data structure and sections stored in the PivotDataSource
component.
TPlannerDataSourceEh
The component is used to store event objects such as TPlannerDataItemEh.
TPlannerControlEh
The visual component-container TPlannerControlEh contains a set of visual components
PlannerView.
TPlannerCalendarPickerEh
The visual component-calendar is designed to navigate through the days of the month.

Installation
Below it will be described how to install EhLib under Delphi XE5.

Unpacking archive
Unpack EhLib archive.
After unpacking you will have next list of directories:
Directories of the library archive:

Installer
Common
Delphi7
Delphi9.Vcl
Delphi2007
BDS2006.Vcl
RADStudio2009
RADStudioXXXX
Demos
Demos\Bin
Demos\Data
LangResources
DataDrivers
DataService
Orders
HLP

Contain source files which are common for all versions of Delphi and C++
Builder.
Contain source files which are specific for Delphi 7.
Contain source files which are specific for Delphi 9.
Contain source files which are specific for Delphi 2007.
Contain source files which are specific for Developer Studio 2006.
Contain source files which are specific for RAD Studio 2009.
Contain source files which are specific for RAD Studio XXXX.
Demonstration projects
Contains the compiled executables major demonstration projects.
(Contains files only in the editorial - EhLib Evaluation)
Contains the database files for the demonstration projects.
Contain resource files for various languages.
Contains additional components that inherit from TDataDriverEh
generators to support data access third party.
Contain files that contain objects that allows to sort data in various types of
datasets.
Contain text files in which described how to register various versions of
EhLib.
Contain help files.

Installing packages.
Automatic installing:
Run Installer\EhLibInstaller.exe program from EhLib archive to install library in Delphi/C++
Builder IDE automatically. In time of installation the program creates folder, copies files,
compile required packages and registers packages in the IDE.
Manual installing:
Here is described how to install the library in RAD Studio XE5. Installation in other versions of
Delphi is performed by analogy.

Create, if necessary, a new folder "EhLib" folder with a Delphi (for example, C:\ RADStudio\12.0
\Components\EhLib).
If you EhLib version with source code then copy to this folder files from Common and
RADStudioXE5 of archive EhLib.
If you have a version of EhLib without source or evaluation-version, then copy the files to this
folder from the folder <EhLib Archive>\RADStudioXE5\Win32\Release. The library without
source code in the folder <EhLib Archive> \Common Files with the extension are Int. These files
contain the original interface of the pas file libraries. These files are conveniently used as
documentation.
By default EhLib contains resource files for the English language. If you need a different
language, you can replace the original resource files (which are already in the
C:\RADStudio\12.0\Components\EhLib) files that are in the appropriate subfolder
LangResources and change them if necessary.
Uninstall previous or evaluation version of EhLib Delphi IDE.
Remove or move to another folder, the following files to prevent this crossing and the new
version EhLib. Delete all files that start with EhLib ___. Bpl, DclEhLib ____. Bpl, EhLib ___. Bpi,
DclEhLib ____. Pbi folder "C: \ Users \ Public \ Documents \ RAD Studio \ 12.0 \ Bpl \", "C: \
Users \ Public \ Documents \ RAD Studio \ 12.0 \ Dcp \ "and" C: \ Users \ Public \ Documents \
RAD Studio \ 12.0 \ Dcp \ ".
Start Delphi and open ("File \ Open ...") project group EhLibProjGroup190.groupproj.
Compile all group packages ("Project \ Build All Projects").
Install all the packages in the IDE, which begin on Dcl______. To do this, use the mouse to
select the package of "Install".
Components EhLib appear in the pages of 'EhLib Controls' and' 'EhLib Components' component
palette.

Instalation note for users who had EhLib 3.X or 4.X:


Note that Delphi IDE does not move components to the new default place on components
palette when you install new version of same component(s). So if you already have EhLib
installed, then after installation new version does not move EhLib components to the 'EhLib'
page. To force Delphi IDE to move components to the default place on components palette do
next:
Open menu: Component->Configure Palette.
Select '[All]' line in Pages listbox.
Click 'Default Pages' button.
Add, (if need) EhLib directory ("C:\Delphi6\EhLib") in Tools->Environment Options->Library->
Library Path.

Troubleshooting.
Problem:
In compilation time
Delphi shows next error:
"Unit AAA compiled with
different version of unit
BBB"
[Fatal Error]
EhLib.dpk(51): File not
found: 'DBSumLst.dcu'

Solution:
1. It can be because Delphi have access to units from old version of
EhLib. Try to remove old version of EhLib completely.
2. It can be because your Delphi or C++ Builder Build number is not
equal to Delphi or C++ Builder Build number under which EhLib was
compiled. See Build number of Delphi and C++ Builder under which
EhLib was compiled below:
It can be, because you did not copy files from Common and Delphi6
directories of EhLib archive to the one directory.
If you have EhLib - source include version then copy files from
Common and Delphi6 directory of EhLib archive to alone directory.

Support Library LCL (Lazarus, Free Pascal) Installation packages for Lazarus.
EhLib is compatible with LCL framework (Lazarus, Free Pascal) for the Win32 platform.
Detail information about support and installation packages for Lazarus read in the file <EhLib
archive> /Lazarus/readme.txt

Installing help files.


Copy EhLib.hlp and EhLib.cnt files from HLP directory of EhLib archive to the Delphi 7 HELP
subdirectory.
Run Delphi IDE.
Select Help|Customize menu to start the OpenHelp application.
Add the EhLib.cnt file to the Contents page, add the EhLib.hlp file to the Index and Link pages.
Select "File->Save Project" menu.
Close OpenHelp application.
To check that EhLib help files have been installed correctly, drop DBGridEh component on the
form and press F1. Delphi IDE have to open help window with information about TDBGridEh
component.
If you want to install help files under several Delphi versions simultaneously (or under C++
Builder and Delphi simultaneously) then you have to create a copy of EhLib.hlp and EhLib.cnt
for every version of Delphi or C++ Builder with individual files name (For instance for Delphi 7
copy files EhLib.hlp andEhLib.cnt to EhLibD6.hlp and EhLibD7.cnt respectively).
Next - need to edit file EhLibD7.cnt. This file contain several ":Include" clause at first lines.
Comment (using semicolon sign) lines that dont contain DELPHI7.OHL word)
:BASE EhLibD7.hlp
:TITLE EhLib library
;:Include bcb4.cfg
;:Include bcb5.ohl
;:Include delphi4.cfg
;:Include DELPHI5.OHL
:Include DELPHI6.OHL.
Copy EhLibD7.hlp and EhLibD7.cnt to Delphi 7 HELP subdirectory and install help files as
described above.

Using TDBGridEh component

Brief description of TDBGridEh, TDataLink and TDataSet.


All below texts are equally pertained in both TDBGridEh component and TDBGrid component.
A TDBGridEh control lets you to view and to edit records in a dataset as a tabular grid format.
TDBGridEh does not store data in itself, it only show data from dataset via TDataLink object.
Every database control have internal TDataLink object to interact with dataset. You can connect
TDBGridEh to dataset using DataSource property. If you already have used TStringGrid
component you can see that data shows in TStringGrid and in TDBGridEh very similarly, but
mechanism that uses to show data in TStringGrid and in TDBGridEh are very different. In
TStringGrid count of rows is equal to rows in array of strings, while in TDBGridEh (and TDBGrid)
count of rows always not more than count of visible rows and although vertical scrollbar can
display thumb position regarding the count of record in dataset, In reality, it take information
not from grid but directly from dataset. TDataSet doesn't allow us to work with data as with
array of data i.e. we cannot quickly get value of the field from certain record. Some types of
datasets have not even such notion as record number (in such datasets we can only know what
we are at the beginning of dataset or at the end of it or somewhere between them. In that case
DBGrid shows vertical scrollbar only in three positions). But to have possibility to draw several
records simultaneously, TDataLink object allows having buffer of records (record buffer
window) for quick random access. DBGrid uses this possibility of datalink and it sets size of
record buffer window equal to count of visible rows in the grid. We cannot control what record
must be first in this buffer, DataLink itself scrolls record buffer window when we navigate
through the dataset. And it controls the scrolling of record buffer window so that the active
record is always in the record buffer window. It is a reason why the active record changes
position when users change thumb position of vertical scrollbar using mouse.

Working with TDBGridEh at design-time.


TDBGridEh contains rows and columns. Every row is a record in TDataSet. Every column is a
field in TDataSet. Columns can be dynamic or static. Dynamic columns are recreated every time
when the state of DataSet is changed. State of DataSet can be changed in several cases. It is
changed when, for example, DataSet is reopened. When column is
recreated, values of column properties are reset to their default
values. It is useful to use dynamic columns when the list of fields of
DataSet is not known in advance. In the mode of static columns grid
itself never recreates columns. At design-time to create static
columns you need to double-click on the grid. The Columns Editor
window will be open. Press Add all fields in this window. Grid will
create static column for every DataSet field.
To customize properties of column you need to select its name in the The Columns Editor
window. You can also select column
in Object Inspector by clicking
column title in the grid. If grid is
connected to DataSource and
DataSource is placed on the same

Form as grid, then icon of DataSource will be shown in the bottom right corner of the Grid. You
can click on the DataSource icon to select DataSource in Object Inspector. In same manner grid
can show DataSet. If a DataSet is a TMemTableEh then grid also can show TDataDriver and
DataSet which is connected to DataDriver as a ProviderDataSet.

Types of columns and data types in columns


Collection has columns - DBGridEh.Columns consists of TColumnEh elements. All columns have
a same type - TColumnEh, but the kind of data displayed in each column is different, and
depends of the type of field assignments through property TColumnEh.FieldName, as well as
the combination of assigned of Column properties. For example, if the field is TBooleanField,
then displays Checkbox a column rather than text. It is possible to setup properties of Column
to display checkboxes for any other type of field, if you set the TColumnEh.Checkboxes
property to True and fill in additional properties. The following instructions describe how to set
the properties of the column to achieve the desired display, behavior and form of the cell
editor.

Access to the grid columns

You can use the following properties and methods for accessing the grid columns:
property DBGridEh.Columns: TDBGridColumnsEh
The main collection of columns
property DBGridEh.VisibleColumns: TColumnsEhList
List of visible columns. The list is automatically updated when you change the
basic list or change the columns visible columns
property DBGridEh.FieldColumns[const FieldName: String]:
TColumnEh
Search a column by name field. If the column, which TColumnEh.FieldName =
FieldName is not found, an exception is thrown.
function FindFieldColumn(const FieldName: String): TColumnEh;
Search column name field. If the column, which TColumnEh.FieldName =
FieldName is not found then it returns nil.
property SortMarkedColumns: TColumnsEhList
List
of
columns wher
sorting
markers
TColumnEh.Title.SortMarker property.

Columns with editor of a Combobox type.

are

set

with

the

The column data type Combobox Editor is a column in which the data
is opened for editing text editor with the ability to select data from the
drop-down list. In the right part of column the editor shows the special
button DropDownEditButton. When clicked, it displays a drop-down
list.
When the grid has a column of Combobox type it is convenient have
edit buttons be always displayed in the column of the grid, but not only
within the text editor in the cell.
To customize the display of buttons, use the following properties:
- TDBGridEh.ColumnDefValues.AlwaysShowEditButton
- TColumnEh.AlwaysShowEditButton
- TDBGridEh.EditButtonsShowOptions
For more details on the edit button, see Working with edit buttons.
Using the properties of the column and the type of field you can configure Column for four
main types Comboboxes:
: PickList Combobox - For this combobox the data for a drop-down list are taken from the
TColumnEh.PickList property. To activate this type combobox just fill TColumnEh.PickList
property by list of possible values. In this mode the drop-down list can contain only one
column, can not display headers or special row SpecRow.
: DataList Combobox - For this type of combobox the data for a drop-down list are taken from a
DataSet specified by TColumnEh.DropDownBox.ListSource property. To activate this type of
combobox assign TColumnEh.DropDownBox.ListSource property by a DataSource which
indicate a DataSet with a list of values.
: KeyPickList Combobox - This mode uses two lists - KeyList and PickList. KeyList contains values
that are stored in the field specified by TColumnEh.FieldName ptoperty, and PickList - in the
relevant index contains the value to be displayed in the column and list. You can also set a
Column.NotInKeyListIndex property by the index from PickList property, which is displayed if
the value of the field is not contained in KeyList (for example, you can specify the index for Nullfield value). You can also set Column.DblClickNextval to True, to allow users to change the value
by double-clicking the mouse.
: LookupCombobox - In this mode, the data for the list are set through a field TField justified as
a lookup field or through the subproperties of TColumn.LookupParams property. See more
details about this mode in the next section "Configuring lookup relationship in columns grid"
Use the following properties of TColumnEh (or TFieldRow for DBVertGridEh) for advanced
configuration and work with LookupCombobox and DataList Combobox:
TColumnEh.CaseInsensitiveTextSearch Specifies that the text search in the drop down
list is case-insensitive.

TColumnEh.LimitTextToListValues limits the ability to enter text only by a text from the
list.
If TColumnEh.LimitTextToListValues = False, then after you enter the text that is not in the list
and attempt to leave the cell, or press Enter the TColumnEh.OnNotInList event is triggered. The
event handler is passed the entered text NewText argument. You can add text to the list. If
the list is based on data from the DataSet, the new value should be added in the DataSet. After
values is added in the DataSet set RecheckInList property to True. For Combobox of
LookupCombobox type the grid re-perform lookup search the list and write the data to the cell.
Configure the lookup relationship in grid columns.

General concepts about lookup fields.


Before describing the possiblites of the grid when working with lookup fields, lets consider what
is a lookup field in terms of the standard TField class. Lookpup field is a field of DataSet with a
TField configured in such a way that it show text from the dictionary field basing on the code of
a key field of dataset. The second DataSet serves as a dictionary. Typically, lookup fields are
created at the Design-Time based on field DataSet selected from the database. When
configuring fields in the DataSet the designer creates a Persistent field based on the selected
fields from the database, and then adds calculated and lookup fields. To configure the lookup
field, you can use a dialog to add a new field in DataSet.

You can also fill TField properties in the Object Inspector as follows:
FieldKind = fkLookup
KeyField = field name that contains the code values in the original DataSet
LookupDataSet = DataSet that contains dictionary values
LookupKeyFields = field name that contains the code values in the dictionary DataSet
LookupResultField = field name in dictionary DataSet whose content should be displayed
instead of the code.
Lookup columns in the grid.

DBGridEh and DBVertGridEh automatically determine then Field.FieldKind is lookup and create
a cell with a dropdown list so that it looks like a LookupComboBox.
In addition, the column (TColumnEh and TFieldRow) contain additional properties for the
empowerment of working with lookup fields.

To display multiple fields in the drop-down list fill the Column.LookupDisplayFields property by
the list of field names separated by a semicolon - ";".
By default, the drop-down list displays a single column with the value specified in the field
TField.LookupResultField. You can customize the list so that it displays multiple fields from the
DataSet specified property TField.LookupDataSet.
Method 1: - Fill TColumnEh.DropDownBox.ListFieldNames property by the list of fields. Several
fields are separated by semicolons - ";".
Method 2: - Fill TColumnEh.DropDownBox.Columns collection with elements. With this
method, you can also customize the font and the other a property of each column drop-down
list.
Configure lookup relationships directly into the grid column.
DBGridEh and DBVertGridEh has the ability to create lookup relationships directly into grid
columns. To do this, use the sub-properties of TColumn.LookupParams property. Fill in the subproperties similar to how it is configured in the TField. In this case, leave TColumn.FieldName
property empty.
The TColumn.LookupParams property has the following subproperties
Property Name

Property Type

Description

KeyFieldNames

String

LookupCache

Boolean

LookupDataSet

TDataSet

Defines a field (or fields) in Grid.DataSource.DataSet


that specifies the value to search LookupDataSet.
Several fields are separated by ';'.
Specifies whether to copy the key values in the
internal buffer to speed up the operation of
drawing a grid of cells.
Specifies the dataset record values to be displayed

LookupDisplayFieldName String
LookupKeyFieldNames

String

in the lookup control instead of the field KeyField


Specify the field whose value will be displayed on
the screen.
Defines a field (or fields) in LookupDataSet value
will be used to search records for the value of the
field specified by KeyFieldNames property.

With a large number of customized lookup columns in the grid, drawing data may be slow
because Search lookup values occurs in each cell drawing. But drawing can be accelerated, if
you use TMemTableEh as a DataSet. MemTableEh provides the ability to create in DBGridEh
associated buffer values found and dynamically obnovlyaet it as data changes MemTableEh.

Advanced Configuration of a drop-down list in Comboboxes.

Use the following TColumnEh properties (TFieldRow for DBVertGridEh) for advanced
configuration of LookupCombobox and DataList Combobox:
AutoDropDown
Specifies that the drop-down list will be displayed automatically when user starts typing
in the Combobox editor.
DropDownRows
Specifies the height of the drop-down list. The height given in the text lines.
DropDownShowTitles
Specifies whether to display the column headings in the drop-down list. The texts are
taken from the header field names or from the collection of columns specified property
TColumnEh.DropDownBox.Columns.
DropDownSizing
Gets or sets a value specifying whether to display sizing bar in the drop-down list. The
sizing bar is displayed in the lower right part of the window below the vertical scroll bar.
DropDownWidth
Specifies the width of the drop-down list. A value of -1 sets an indication that the width
is calculated automatically based on the width of the specified fields.
DropDownSpecRow
See the section Using
DBLookupComboBoxEh.

SpecRow

columns

and

components

DBGridEh

DropDownBox.AutoFitColWidths
Gets or sets the value indicating the total width of the columns in the drop down list will
always be fited to the width of the client window.
DropDownBox.ColumnDefValues
Defines the value values for the properties for all columns of a drop-down list.

DropDownBox.ListSource
This property can be used for several cases.
1. You can assign the this property by DataSource which refers to special DataSet with a list
of values that is different from the list of the values set in TField.LookupDataSet. For
example, DataSet specified in DBGridEh.DataSrouce.DataSet and DataSet specified in
TColumnEh.DropDownBox.ListSource.DataSet in a relationship Maset-Detail. When you
select a record in DBGridEh, the Maset-Detail attitude fills a list in ListSource.DataSet by
the desired values, which will be displayed when the user clicks the to open drop-down
list in a text editor on the grid for this lookup column.
2. You can adjust the drop-down list to filter data as you type text a cell editor. For detailed
information, see "Filtering Data in lookup dropdown lists when typing"
DropDownBox.ListSourceAutoFilter
See the section "Filtering data lookup dropdown lists when typing"
DropDownBox.ListSourceAutoFilterType
See the section "Filtering data lookup dropdown lists when typing"
DropDownBox.Options
It allows you to set some properties of the drop-down list, such as display dividing lines,
set markers sorting on title click.
DropDownBox.SortLocal
Gets or sets a value indicating that when you click on the title in the drop-down list you
need to sort locally within the DataSet. To customize the sorting and specify the
required values in the property DropDownBox.Options Title.TitleButton and set to True
in the property DropDownBox.AutoFitColWidths.
DropDownBox.UseMultiTitle
Show titles dropdown in MultiTitle mode. Detailed information on the MultiTitle mode
see the section - "Complex headlines."

Checkboxes for Boolean and non Boolean fields.

Grid automatically shows checkboxes for Boolean fields. To show checkboxes for no Boolean
fields, fill first line of Column.KeyList property by value (or values) that corresponds to the
checked state of the checkbox. Fill second line for non-checked state, and set
Column.Checkboxes property to True. One line of KeyList can contain more than one value. In
that case every value must be separated by semicolon.
Drawing of a ProgressBar shaped image in the Grids cell.

Grid doesnt allow customizing column to show ProgressBar shaped image, but there is a
procedure DrawProgressBarEh in the ToolCtrlsEh module. You can use it to
draw image of ProgressBar when an event of custom drawing of a Grids cell is
used.

Below you can see an example of using of the DrawProgressBarEh procedure:


procedure TForm1.DBGridEh6Columns3AdvDrawDataCell(Sender:
TCustomDBGridEh;
Cell, AreaCell: TGridCoord; Column: TColumnEh; const ARect: TRect;
var Params: TColCellParamsEh; var Processed: Boolean);
begin
Sender.DefaultDrawColumnDataCell(Cell, AreaCell, Column, ARect,
Params);
DrawProgressBarEh(mtTable1.FieldByName('ItemsTotal').AsFloat, 0,
50000,
Sender.Canvas, ARect, clSkyBlue, cl3DDkShadow, clNone);
Processed := True;
end;
Showing bitmaps in data cells depending on the field values.

TDBGridEh allows to show bitmaps from TImageList component depending on the field values.
In order to show bitmaps you need:
1. Fill list Column.KeyList property by the possible field values (every value in the separated
line) and set Column.ImageList property by the TImageList control that has the bitmaps. Every
image in ImageList corresponds to the string line in the KeyList property. You can also set
Column.NotInKeyListIndex property to the index of bitmap that will be shown if the field's value
does not correspond to any value in the KeyList (for instance you can set index of image for Null
field value). At run time you cant edit cells with bitmaps. Use SPACE key or mouse click to set
value from next line of Column.KeyList to the field. Use Shift+SPACE key or Shift+Mouse click to
set value from previous line Column.KeyList. You can also set Column.DblClickNextval to True to
allow changing values in cell by double mouse clicking.

Showing pictures from DataSet fields in the grid cells.

DBGridEh can display images in the data cells in the following formats:
BMP, JPeg,
GIF - From Developer Studio 2007
PNG - From RAD Studio 2009.
To enable the display of graphics data set DBGridEh.DrawGraphicData to True. The grid will display
graphical information for the fields of type TGraphicField and TBlobField who BlobType =
ftGraphic.Default. DBGridEh recognizes only format like TBitmap. For the addition of graphical
modules use the property DBGridEh.IncludeImageModules: TIncludeImageModulesEh;
TIncludeImageModuleEh = (
iimJpegImageModuleEh, - plug-in to display the data in a format JPeg
iimGIFImageModuleEh, - plug-in to display the data in the format of GIF
iimPNGImageModuleEh - plug-in to display the data in PNG
);

This property should only be used in Design-Time compilation via IDE. Setting this property causes the
IDE to add additional modules in the module uses the form.

Demo:

See a Demo project that display image data in the cells of the grid

in library archive <EhLib Dir\Demos\DBGridEh.DrawBlobImagesInCell>


Draw memo fields.

To draw memo fields as text set DrawMemoText to True.


Dropdown calendar.

For TDateField and TDateTimeField fields Inplace Editor will show dropdown button to show
dropdown calendar. Set Column.ButtonStyle to cbsNone to prevent showing the dropdown
button.
The text in a cell as a link

Use the property CellDataIsLink of DBGridEh.TColumnEh and DBVertGridEh.TFieldRowEh


classes to customize the text or a picture in a grid cell in such a way that it looks like a link.
Ie when you point the mouse to the text the
cursor icon changes the view of the cursor to
the type of "index finger" and draws the text in
a cell type in "Underline" style.
When you click on the link the
TAxisBarEh.OnCellDataLinkClick event occurs.
It is possible to define a link state for each
DataSet record.
To do this, write an event handler for TAxisBarEh.OnGetCellParams event and set
Params.TextIsLink or Params.ImageIsLink.
True value in the TextIsLink property of Params argument specifies that the text in the cell have
to be appeared and respond to the mouse as a reference.
True value in the ImageIsLink property of Params argument specifies that the image from
TColumnEh.ImageList in the cell have to be appeared and respond to the mouse as a reference.
See a demo project in the folder <EhLib Archive>/DEMOS/CellDataIsLink

Default values for title properties.

Use TDBGridEh.ColumnDefValues.Title property to set default values for title properties.

Other features and events column TColumnEh.

TColumnEh.Increment - Specifies the increment value when the edit button is


Column.ButtonStyle have a bsUpDown or cbsAltUpDown value and Column.Field have a
numbric type.

Enable / Disable editing data in the Grid


To completely disable the ability to change any data in the grid set DBGridEh.ReadOnly
property to True. To restrict the editing of data in a particular column, select a similar property
in the TColumnEh (TColumnEh.ReadOnly).
Using the property DBGridEh.Enabled you can disable Grid and any of its elements that can
receive focus. It is possible to prevent open a text editor open the cells, which opens by default
on the F2 button or Enter. To prevent the text editor set TColumnEh.TextEditing property to
True. To prevent displaying a text editor for the whole grid, remove the dgEditing value from
the DBGridEh.Options property.
To prevent or allow certain operations over the records use DBGridEh.AllowedOperations
property.
The DBGridEh.AllowedOperations property is TDBGridEhAllowedOperations type and can
contain the following values:
alopInsertEh Insert new recordings at any place of the grid (actually DataSet) is
allowed.
alopUpdateEh Changing the values of an existing entry is allowed.
alopDeleteEh Deleting records is allowed.
alopAppendEh Adding entries to the end of the grid is allowed.
To enable or disable the change only in a certain cell of a grid is necessary to use the event of
TColumnEh object.
The TColumnEh.OnGetCellParams event is of TGetColCellParamsEventEh type and has the
following call parameters
Sender: TObject;
Grid olumn that caused the event
EditMode: Boolean; The value is True if the event is caused by cell text editor.
This same event is called when grid render a cell. In this case
EditMode equals False.
Params: TColCellParamsEh Additional parameters of the event
Use Params.ReadOnly property to prohibition or permission data changes in a cell. You can set
a property of Params.TextEditing option to enable or disable a text editor in the cell.
In the following example, a handler prohibits changing the text in column 1 if the value of the
field Field1 in the current record > 0.

At the time of the call, the grid will be on the required record of DataSet. With a property of
DataSet, you can get the value of all the fields of the record. In the event you can not set
properties of the grid or column.

The control data input in the InplaceEditor


After the user has entered the data in the cell editor and press Enter, or tried to move to the
next cell the grid transfers the data entered from the editor in the Field like this Field.AsString
:= InplaceEditor.Text.
Before the data transfer the TColumnEh.OnUpdateData event occurs, where you can perform
additional checks, replace the text or to take on itself the management of data entry in the field
Field.
The event has the following parameters:
Sender: TObject
TColumnEh that calls the event.
var Text: string
The text from the editor of the cell to be written into the field.
var Value: Variant The value of the cell editor in a variable of type Variant. In
some cases, the value is passed as Variant type. To determine
which of the two variable contains the value use UseText
parameter.
var UseText: Boolean
Determines which parameter Text or Value should be used
to record the values in the field.
var Handled: Boolean
Set Handled to True to indicate that you have processed
the event and do not need to call a method to write the value
in the field by default.
In this event, you can change the Text and the Value that will record in the DataSet. You can
also change UseText value to indicate which parameter should be used for recording. If it is
used Value parameter, the recording will TField.AsVariant property to write value.
You are free to write the value in the field using the following code:
procedure TForm1.DBGridEh1Columns2UpdateData(Sender: TObject; var Text: string;
var Value: Variant; var UseText, Handled: Boolean);
begin
if UseText
then TColumnEh(Sender).Field.AsString := Text
else TColumnEh(Sender).Field.AsVariant := Value;
Handled := True;
end;

You can also directly call the DataSet.Post to finish editing the recording immediately after
recording the data in the field.

Moving and resizing columns in the grid.


Use the TColumnEh.Width property to set the width of the column. You can use a
TColumnEh.MaxWidth and TColumnEh.MinWidth property to limit the maximum and minimum
width of the column. Usually it is necessary when the user is allowed to change the column
width with the mouse. To allow the change column widths in Run-Time, set in a property of
dghColumnResize TDBGridEh.OptionsEh. The same value is present in the properties
dgColumnResize TDBGridEh.Options. If dgColumnResize value is set, then it is allowed to
change as the width of the columns and column moving. This property is deprecated.The
dghColumnResize value in TDBGridEh.OptionsEh property only affects changing the width.

After changing the width of the column After changing the width of the column is called the
DBGridEh.OnColWidthsChanged event is called.
In the grid it is possible to adjust the width of the columns so that they occupy the entire width
of the visible area of the grid, and did not extend beyond the visible area.
Set TDBGridEh.AutoFitColWidths to True to automatically change the column width so that the
width will be equal to the entire grid visible part of the window. Additional property
TDBGridEh.MinAutoFitWidth specifies the minimum width of the grid at which the change in
width. Use TColumnEh.AutoFitColWidth property of the grid columns at to further determine
whether the column is used for fitting the width of all columns to the width of the visible area.
To allow the mouse to move the columns in the Run-Time, set in the property dghColumnMove
TDBGridEh.OptionsEh. After the column is moved the TDBGridEh.OnColumnMoved event
occurs.
Use the following methods to control the width of columns:
procedure OptimizeColsWidth(ColumnsList: TColumnsEhList; const
CheckRowCount : Integer = -1; const MaxWaitingTime: Integer = 0);
Optimizes the column width so that the entire text of the column could be seen inside
the cell. ColumnsList parameter specifies the list of columns for which it is necessary to
perform optimization. CheckRowCount parameter specifies the number of records that
need to get around to perform optimization. This parameter is set to limit the time of
the method. MaxWaitingTime parameter specifies the maximum period of the method.
Inside a method grid runs through all the records DataSet. If the option is
MaxWaitingTime method adjourned once it reaches the specified value.
procedure OptimizeAllColsWidth(const CheckRowCount : Integer = -1;
const MaxWaitingTime: Integer = 0);
The method works similarly to the previous method, but perform optimization for all the
columns in the grid.

Visibility columns in the grid


Use the TColumnEh.Visible property of the column to hide or show a column. To access the
array of all columns, including hidden, use TDBGridEh.Columns property
TDBGridEh.Columns[i].Visible :=

To get a list of all visible columns, use TDBGridEh.VisibleColumns property.


var
i: Integer;
w: Integer;
begin
for i := 0 to DBGridEh1.VisibleColumns.Count-1 do
w := DBGridEh1.VisibleColumns[i].Width;
end;

Fonts and coloring of the data grid


Working with the Grid Fonts
Use TDBGridEh.Font property to set the font for the entire grid. Changing the properties of
TDBGridEh.Font will affect all cells of the grid that use the font "Default" or "Not stored". For
example, if you change the font in the column grid - TColumnEh.Font, font properties are
locked at the column level, and it will always use the font TColumnEh.Font no matter how the
TDBGridEh.Font. To return the column to the state when they are using the font
TDBGridEh.Font it must be removed from the property value cvFont
TColumnEh.AssignedValues. Each element of the grid, which have the Font property, has the
additional property to set the state "use the default font" This property has a name a
AssignedValues or ParentFont. For example, to work with the font header columns use
properties TitleParams.Font of TFont type and TitleParams.ParentFont of Boolean type.
The background color of the cells in the grid
To set the background grid use the TDBGridEh.Color and TDBGridEh.FixedColor properties.
TDBGridEh.Color property is responsible for the background color in the cells of data and the
areas not shaded cells. TDBGridEh.FixedColor property is responsible for the color of the fixed
cells. Changing of the TDBGridEh.Color property will affect the entire grid cell that uses the
background color of the "default" or "Not stored" state. For example, if you change the color in
the column grid TColumnEh.Color, the color will be fixed at the column level, and it will always
use the TColumnEh.Color regardless of how the property TDBGridEh.Color is changed. To return
the column to the state when they use color TDBGridEh.Color the cvColor value must be
removed TColumnEh.AssignedValues property. Each element of the grid which have a of Color
property, also has the additional property to set the "use color by default." This property has a
a AssignedValues or ParentColor name.
Font and background data cells
To customize the font and background colors of cells with data using the following properties:
Columns[i].Font, Columns[i].Color to set the font and background colors for a
particular column
EvenRowColor, OddRowColor to set the color even and odd entries in the grid. To
work correctly, the DataSet must correctly return the record number through the
property DataSet.RecNo.
3D flat grid style.
Use the property TDBGridEh.OptionsEh to display / hide the frame around the 3D-fixed, fixed,
footers and rows of data.
Use TDBGridEh.Flat property to display the grid in the "flat-style".
Style display of the selected cell and the selection
By default, the grid automatically adjusts the style of shading selected cell and fixed-grid areas,
depending on the color scheme Windiws and project settings in IDE Project Options->
Application-> Runtime thems.

In Classic mode, the cell is painted with a solid


color

Themed mode uses a grid class objects


Vcl.Themes.StyleServices to fill cells in a
certain style.
You can set the style of the selected cell staining for each individual using the
SelectionDrawParams.SelectionStyle and SelectionDrawParams.DrawFocusFrame property.
You can also set the style of the selected cell globally for all project Grids. To do this, use the
properties of the global object and GridsEh.GridDefaultDrawStyleEh.SelectionStyle
GridsEh.GridDefaultDrawStyleEh.DrawFocusFrame.
Selecting and highlighting the current record
To activate, when the grid is always select the whole record, set dgRowSelect value in the
Options property.
To illuminate the current record in the grid, set dghRowHighlight value in the OptionsEh
property.

The properties for formatting the data in the grid


Use the following properties of the grid column TColumnEh to format the data in the cell:
Property Name

Property Type

Description

DisplayFormat

String

The output format is a numerical value or a TDateTime


value.

EndEllipsis

Boolean

Display ellipsis if the text does not fit in a cell grid

Layout

TTextLayout

Vertical text alignment

Alignment

TAlignment

Align text horizontally

WordWrap

Boolean

Wrap text if it is not fit to a cell in one row. The text


will be moved if the row height (Row) greater than the
height of one line of text.

EditMask

String

Mask text when editing the data in the cell. To


correctly read the description of the filling properties
of the standard properties TEditMask

Events to customize cells font attributes and color.


There are several events that allow you to customize cells font attributes and color before the
cell data will be drawn. In the time of calling these events the DataSet is positioned on the
record that need to draw, so in the events you can access field values using such methods as
TDataSet.FieldByName(..).Value. Do not change grid properties or columns properties in these
events. It can bring to recirculation of the program.

TDBGridEh.OnDrawColumnCell
Write OnDrawColumnCell event to overload the standard method of the drawing cell. This
event is called after standard drawing, so the information will be drawn above standard-drawn
contents of cell. You may print the additional data, using methods of
TDBGridEh(Sender).Canvas property.
TDBGridEh.OnDrawDataCell
Do not write an OnDrawDataCell event handler. OnDrawDataCell is obsolete and included for
backward compatibility.
TColumnEh.OnAdvDrawDataCell or
TDBGridEh.OnAdvDrawDataCell
Write this event to draw data in the grid cell. In code of the event we set Processed parameter
in True value to define that the process of drawing was performed in event. Otherwise grid will
call method for default drawing of cell data. You may, if necessary, change such parameters as
ARect or Params. After changing the parameters call Grid.DefaultDrawColumnDataCell method
and set Processed to True value. You can also leave Processed parameter in False state and
dont call Grid.DefaultDrawColumnDataCell. In that case, grid will call default drawing
procedure using changed parameters. Use Grid.Canvas property to draw data in the cell by
yourself.
TDBGridEh.OnGetCellParams or
Sender: TObject

Grid, that call the Event

Column: TColumnEh

The column for which the event is called

AFont: TFont

Font that will be used to paint a cell. You can change the font
properties to specify properties of the new font rendering.

var Background: TColor

The background color that will be used to paint a cell. You can
change this parameter to specify a new color.

State: TGridDrawState

The status of the cell.

TColumnEh.OnGetCellParams
Write OnGetCellParams event to set such parameters as Font, cell color or other parameters of
cell before cell will be drawn. If it is needed to change parameters only in a specified column
then use column event - TColumnEh.OnGetCellParams. In this event you may change Font,
Color, Alignment, ImageIndex, Text, checkbox's state and also such properties of a Params
parameter as:
BlankCell: Boolean. Set this property to true to show cell as an empty cell with 3D
border.
SuppressActiveCellColor: Boolean. Set this property to forbid the color of active cell to
overlay the color that is set in Background property.
TextEditing: Boolean. Set this property to forbid showing of cell text editor.
These events are also called when grid request Font and Color for inplace editor.
If you want to draw data by yourself use OnAdvDrawDataCell event.
Use this event to replace the cell parameters for particular column before rendering. This event
has an expanded set of parameters compared to the TDBGridEh.OnGetCellParams event.

This event is fired, not only before rendering a grid. In some cases, the event is called to request
additional cell parameters. For example, before opening InplaceEditor grids causing the event
and check Params.TextEditing option to allow you to open InplaceEditor for the current cell.
The event has the following parameters TColumnEh.OnGetCellParams:
Sender: TObject

Grid, which causes Event

EditMode: Boolean

The value is True if the event is caused by cell text editor.


This same event is called when rendering a grid cell. In
this case EditMode equals False.

Params: TColCellParamsEh

Additional parameters rendering. You can change the


properties of this parameter in the event handler to
change the format of the rendering of the current cell.

Params.Alignment: TAlignment

Text alignment.

Params.Background: TColor

background color

Params.BlankCell: Boolean

An empty cell with 3D frame

Params.SuppressActiveCellColor:
Boolean
Params.CheckboxState:TCheckBoxState

Use color Params.Background even if it is a current cell

Params.Col: Longint

Column number of the cell, which is drawn at the


moment.

Params.CellRect: TRect

The size and the cell borders

Params.Font: TFont

Font to be used for drawing text

Params.ImageIndex: Integer

Number of pictures from Column.ImageList

Params.ReadOnly: Boolean

The cell read-only

Params.Row: Longint

Row cell line number, which is drawn at this point.

Params.State: TGridDrawState

Cell status

Params.Text: String

The text to be rendered in the cell

Params.TextEditing: Boolean

For the current cell, it is allowed to open InplaceEditor

Params.DrawCellByThemes:Boolean

Draw the cell background using the scheme.

Params.TextIsLink: Boolean

The text in the cell is a link reference.

Params.ImageIsLink: Boolean

Picture from Column.ImageList a link reference.

Checkbox status if the column is set to show checkboxes

Default values for column properties.


To set default values for column properties use ColumnDefValues property. New created
columns will take property values from ColumnDefValues properties and will hold them till first
assign new value.

Data row height.


Use RowHeight and RowLines properties to specify the height of data row. Full height of data
row is calculated as height in text lines of RowLines plus RowHeight. Set RowSizingAllowed to
True value so that user can change height of row using mouse at run time.

Set Column.WordWrap to True value to break a long text in data row to a multiline. In reality,
text will be wrapped only when height of row is bigger than height of one text line.

Individual height of each data row.


TDBGridEh can work in mode when the height of every row is calculated dynamically depending
on the text in the grid cells or size of image in the cell (When DrawGraphicData value is True).
Include dghAutoFitRowHeight in OptionsEh property to force grid to calculate height for every
row. This mode works only when the grid is connected to the DataSet of TMemTableEh type
and TMemTableEh is not in TreeView mode. When dghAutoFitRowHeight is included, grid
calculates the height of the row dynamically using cell text (TColumnEh.WordWrap property
also influence it) and for column the fields of which have ftGraphic type. To avoid surplus
recalculation, grid recalculates heights, but not for after every change of properties. For
instance, grid does not update heights if the Font property was changed. In such cases it is
necessary to call UpdateAllDataRowHeights method. For more flexible calculation of the
heights the grid has an OnGetRowHeight event, in which you can specify the height of row.
During the event calling, the MemTableEh positions on record and we can calculate the height
of this record, so you can use MemTableEh properties to access fields values.

Events and properties to control the reaction of the mouse.


The grid contains the standard event OnMouseDown; OnMouseMove; OnMouseUp; to handle
mouse events.
In the event you can use the following methods to determine the number of the cell that
worked Event
function MouseCoord(X, Y: Integer): TGridCoord;
event returns the position of the cell in the coordinates of the client area of the grid.
If X, Y coordinates do not fall in a cell, one of the values or TGridCoord.X TGridCoord.Y will be 1.
Grid provides a set of events in which the coordinates are transmitted cells in which there was
a click.
TDBGridEh.OnCellClick
The event occurs only when you click on the cells in the data section.
The event is passed a column Column: TColumnEh, which clicked.
TDBGridEh.OnCellMouseClick
The event occurs when user clicks any cell in the grid.
The event have the following parameters
Grid: TCustomGridEh
Grid in which the event occurred
Cell: TGridCoord
The cell in which the event occurred
Button: TMouseButton Type of pressed button
Shift: TShiftState;
State of additional buttons
X, Y: Integer;
The coordinates of the mouse relative to the cell

var Processed: Boolean Set Processed in True to indicate that you have been
treated in a reaction event and call the default handler is
not necessary.
In the event you can call the default handler - TCustomGridEh. DefaultCellMouseClick.
Useful methods and properties for obtaining data on the area of the grid in which the event
occurred:
function GetCellAreaType(ACol, ARow: Integer; var AreaCol, AreaRow:
Integer): TCellAreaTypeEh;
get the type of horizontal and vertical grid area in which the event occurred.
Horizontally the grid is divided into the following areas:
hctIndicatorEh
Indicator area
hctDataEh
Data area
Vertically the grid is divided into the following areas:
vctTitleEh
header area
vctSubTitleEh
The area under the heading filter
vctDataEh
data area
vctAboveFooterEh The area between the footer and data
vctFooterEh
footer area
TDBGridEh.OnGetBtnParams
Event occurs by clicking on the header and is used for special painting of a pressed title.
TDBGridEh.OnTitleBtnClick
The event is called when you click in the header area that is configured to work as a button. To
trigger events in the header the Column.Title.TitleButton property should be set to True.
TDBGridEh.OnTitleClick
The event is called when you click in the header area.

Events and properties to control the reaction of the keyboard.


The standard grid presentedin OnKeyDown; OnKeyPress; OnKeyUp; events for processing
keyboard.
Use these events to track when input focus enters the column and leaves it - OnColEnter
OnColExit.

Setting color dividing lines, the presence / absence of lines in various areas Grid.

It is possible to set the color


and determine the presence or absence of dividing lines for the grid in general and for specific areas
including the header area of the indicator area SubtitleFilter, data area and basement area (footer).

Next properties are responsible for the presence of lines and colors in the grid:
Presence / absence of values dgColLines, dgRowLines in property TDBGridEh.Options:
Set the presence of vertical and horizontal lines for the Grid in general.
Sub-properties of the property TDBGridEh.GridLineParams:
Using sub-properties of this property you can control the color of the dark lines in the grid
(DarkColor) and the color of bright lines (BrightColor), the color of the lines in the data,
the presence of lines of data, and the color scheme of the lines.
Sub-properties of the property TDBGridEh.GridLineParams
Property Name
DarkColor

Property Type
TColor

BrightColor

TColor

DataVertColor
DataVertLines
DataHorzColor
DataHorzLines
DataBoundaryColor

TColor
Boolean
TColor
Boolean
TColor

GridBoundaries

Boolean

ColorScheme

TDBGridLines
ColorSchemeEh

Description
Color dark lines. Used for areas of fixed cells, as well
as areas within the meaning of which is meant shading
dark lines.
ClDefault value determines what color will be
determined automatically based on the current color
scheme, the properties of Grid.Flat and activity of
global change Themes.Active.
Color bright lines. Used for data areas, and areas
within the meaning of which is meant shading light
lines.
ClDefault value determines the color will be
automatically detected similarly DarkColor.
Color vertical lines in the data area.
The existence of vertical lines in the data.
Color of the horizontal lines in the data area.
The presence of horizontal lines in the data.
Painted boundary lines grid (not to be confused with
the client area) color DarkColor.
Paint boundary lines grid (not to be confused with the
client area) color DarkColor.
Property determines the color scheme used to draw
the dividing lines for which a color clDefault.
Property can contain the following values:
glcsDefaultEh - Use the default color
scheme.

VertEmptySpaceStyle TDrawEmpty
SpaceStyle

glcsClassicEh - The classic filling.Black lines


for fixed areas. Gray lines for the data area.
glcsFlatEh - On
glcsThemedEh VertEmptySpaceStyle property specifies the mode of
filling lines and columns for the empty space between
the last record of the grid and the bottom of the
window.
Property can contain the following values:
dessNonEh - Do not paint.
dessSolidEh - Use solid dividing lines and colors of the
columns.
dessGradiendEh - use gradient shading solid dividing
lines and colors of the columns.

The colors and the lines in the header area:


property
property
property
property

TDBGridEh.TitleParams.VertLineColor: TColor
TDBGridEh.TitleParams.VertLines: Boolean
TDBGridEh.TitleParams.HorzLineColor: TColor
TDBGridEh.TitleParams.HorzLines: Boolean

The colors and the lines in the display:


property
property
property
property

TDBGridEh.IndicatorParams.HorzLineColor: TColor
TDBGridEh.IndicatorParams.HorzLines: Boolean
TDBGridEh.IndicatorParams.VertLineColor: TColor
TDBGridEh.IndicatorParams.VertLines: Boolean

The colors and the lines in the basement (footer):


property
property
property
property

TDBGridEh.FooterParams.HorzLineColor: TColor
TDBGridEh.FooterParams.HorzLines: Boolean
TDBGridEh.FooterParams.VertLineColor: TColor
TDBGridEh.FooterParams.VertLines: Boolean

Panel of detail information for record RowDetailPanel.


Subproperties of RowDetailPanel property allow you to create and customize the panel of
detailed information for grid rows. Panel if detailed information is a special area inside grid
where you can put any control from Component Palette on it. At design-time a panel is always
opened under the current record. At
run-time panel is hidden, and there is
a + sign at the beginning part of
every row. You can click + sign to
open panel. At once time panel can
be opened only for one row. You can
also
open
panel
using
key
combination Ctrl-Down or key +. Use
Ctrl-Up to return from panel to grid
row. Use * key to show or hide panel
depending on current state.

Subproperties of RowDatailPanel propery:


Active: Boolean;
this propery allows activating panel of detailed information.
Width: Integer;
width of panel
Height: Integer;
height of panel
ActiveControl: TWinControl; use this property to define control which will be focused when
panel is opening.
BevelEdges: TBevelEdges, BevelInner: TBevelCut, BevelOuter: TBevelCut, BevelKind:
TBevelKind, BevelWidth: TBevelWidth, BorderStyle: TBorderStyle: Use
these
properties to control border style of panel.
Color: TColor;
Color of panel
ParentColor: Boolean Property defines if it is need to use color of grid as a color of panel.
Public
Visible: Boolean
This property defines if panel is visible. You can set this property at runtime for reading and writing.
Use event OnCheckRowHaveDetailPanel to control of panel showing in grid. You can set
parameter RowHaveDetailPanel to allow or forbid panel for required record.
Use events OnRowDetailPanelHide and OnRowDetailPanelShow to execute special action after
panel is hidden or before panel is openened.

RowPanel mode.
Grid can work in special mode when every cell of grid can be placed under each other and can
have individual height. Set RowPanel.Active to True value to activate this mode. At design-time
you can place cell, vertical
and horizontal size. At runtime the possibility to
change position of cell
depends on the presence
dghColumnMove value in
OptionsEh
property.
Possibility
to
change
vertical size of cell depends
on
RowSizingAllowed
property.
When user change cell width, the grid also changes width of adjoined cells which are placed
under or above of changing cell and if the right border of these cells match. By analogy when
user changes cell height, grid changes height of cells in left or right part of grid if low borders
march. Press and hold Shift key to change the size of only single cell.

To change cell height of cell you need to move mouse cursor to the low border of the title cell.
Mouse cursor will change its image from arrow to two arrows with up and down direction. At
this moment press right mouse button and change size.
To change position of cell you need to press right mouse button on the title cell and drag it to
the required place.
Additional subproperies of the RowPanel property:
NavKeysNavigationType: TGridRowPanelNavKeysNavigationTypeEh defines the order of navigation
over cells in the grid when keys Up, Down, Left, Right are pressed.
rpntRowToRowEh - (by default) Keys Up, Down move current cell to next or previouse record of
dataset. Keys Left, Rigth worksas Tab and Shift-Tab.
rpntCellToCellEh Keys Up, Down move current cell to under or above last position from the
current cell. Keys Left, Rigth move current cell to left or right position from the current cell.
TabNavigationType: TGridRowPanelTabNavigationTypeEh

defines an order of going through cells

of the grid by Tab key


rpntUpToDownPriorityEh Go, at first, from top to bottom, than from left to right.
rpntLeftToRightPriorityEh Go, at first, from left to right, than from top to bottom.

Working with datain grouping mode.


Grid allows to group data in memory using columns as a grouping criterions.
You can create and change
grouping at design-time and at
run-time.
The grouping works only when
grid is connected to dataset of
TMemTableEh type.
When grid group data it also sort
data in MemTableEh to have
correspondence of data in the
gtid and in the MemTable. The
Grid track data in the MemTable
and
moves
records
in
corresponding groups when data
are changed. Use subproperties
of Grid.DataGrouping property to
control
grouping.
Use
Grid.DataGrouping.GroupLevels
property to create structure of
grouping. GroupLevels is a
collection
of
TDBGridEhDataGroupLevelEh.
Every item of collection corresponds one level of grouping. The key property of the item of
collection is the ColumnName property of String type. This property keeps name of the column
of field for which the records will be group. Use TColumnEh.Name property to get the name of
the column at run-time. Use Font and Color properties of structures items to control the
format of the grouping records. Set Grid.DataGrouping.Active to True to activate the grouping.
Set GroupPanelVisible property to True to show the current active structure of the grouping.
Special panel will be shown with active items of grouping at the top part of the gird. The

element of the grouping collection is active when its ColumnName property holds a name of a
column. After activation of grouping panel, you can make and change the grouping structure
using drag-n-drop operations. Drag the column title to the grouping panel to group data by this
column. In time of forming the tree of grouping, grid creates the new group record when the
value of the field of column Column.Field is changed. You can change key value of grouping in
the event TDBGridEhDataGroupLevelEh.OnGetKeyValue or TColumnsEh.OnGroupGetKeyValue.
Take current value of the key value from the field GroupLevel.Column.Field.Value. Write the
changed value to the KeyValue parameter of the event procedure.
For example, next event will form tree of grouping that will have only two grouping records Big and Small for
numeric field that have record values that bigger or smaller them 100.
procedure TForm1.gridFishColumns6GroupGetKeyValue(Sender: TCustomDBGridEh;
Column: TColumnEh; var KeyValue: Variant);
begin
if Column.Field.AsFloat > 100 then
KeyValue := 'Big'
else
KeyValue := 'Small';
end;

Grid uses key value to form string that will be shown in the grouping row. If you changed key
value of the grouping, then you likely need to change algorithm that convert key value to
display value for display. Write OnGetKeyValueAsText event to do it. Write
Grid.OnDataGroupGetRowText and GroupLevels.OnGetGroupRowText to rewrite the algorithm
of forming the text that is shown in the grouping row.
Use property Grid.DataGrouping.GroupDataTree to access the items of grouping tree. The
property have the TGridGroupDataTreeEh type and is inherited form TTreeListEh. The itmes of
TTreeListEh class form the tree-type structure of groups and references to DataSet records for
the lowest levels of grouping. Use properties FlatVisibleCount and FlatVisibleItem[Index] to
access items as a flat list. The flat list FlatVisibleItem contain only items which are in the scope
of the expanded nodes. Amount of items in flat array corresponds amount of rows in the grid.
Every item of array is a reference to the instance of TGroupDataTreeNodeEh class and defines a
node in the grouping tree. Basic properties of this class are:
Count: Integer;
Amount of nodes in the group. Nodes can be over groups of lower level or references to
dataset records.
DataGroup: TGridDataGroupLevelEh
Reference to item of grouping structure. Not empty if the node is a node of group.
DataSetRecordViewNo: Integer.
Number of record in MemTableEh. Not empty if the node is a node of the dataset
record.
Expanded: Boolean.
Node is expanded.
Items[Index: Integer]: TGroupDataTreeNodeEh.
List of nodes of the lower level.
KeyValue: Variant;

Level: Integer
The number of node level;
NodeType: TGroupDataTreeNodeTypeEh.
Type of the node. The Node of a group level or a record level.
Parent.
A pointer to the parent branch.
Use Items property of Grid.DataGrouping.GroupDataTree to access the grouping tree as a treetype structure. Every item of this list is a reference to a tree node of grouping of highest level.
Grid.DataGrouping property has next subproperties:
Active: Boolean

Set this property to active grouping in the grid.


DefaultStateExpanded: Boolean

Define Expanded state for every new group node.


GroupLevels: TGridDataGroupLevelsEh

Collection of the grouping structure. Use this property to define template of grouping.
GroupPanelVisible: Boolean

Set this property to True to show panel of grouping in the top part of the grid. When the
panel is visible you can form the structure of grouping by dragging the title of the
column onto this panel.
Font: TFont

Defines default Font of grouping records.


Color: TColor

Defines default Color of grouping records.


Write Grid.OnActiveGroupingStructChanged to take action when the structure of grouping is
changed.
Grid calls OnDataGroupGetRowParams before drawing of a group record.
In the event you can change Text, Color,
Font and add Image from ImageList on
the left of the text.
When the event is calling the DataSet is
positioned on the first record in the
group. So you can access field values of Dataset inside the event.
The event has next type and declaration:
TDBGridEhDataGroupGetGroupRowParamsEvent = procedure ( Sender:
TCustomDBGridEh; GroupDataTreeNode: TGroupDataTreeNodeEh; Params:
TGroupRowParamsEh) of object;

TGroupRowParamsEh type has next properties:


property Color: TColor;
// Color of the cell background
property
property
property
property
property

Font: TFont;
// Font of the text
Images: TCustomImageList; // ImageList to show images
ImageIndex: Integer;
// Index of a image from the ImageList.
GroupRowText: String;
// Text to show in the cell of the group
State: TGridDrawState; // Readonly property. Draw state.

DBGridEh allows you to customize headers groups including the following string parameters:
height, font and color of the grouping records, and the thickness and color of a horizontal
dividing line.

Sub-properties of property TDBGridEh.DataGrouping


Property Name
Property Type
Description
Active
Boolean
Specifies that the group mode is enabled.
(Group only works when connected to the
Grid DataSet type TMemTableEh).
Color
TColor
The background color of the flash.
Font
TFont
Font group records.
GroupLevels
TGridData
Collection group levels. Key groups is the
GroupLevelsEh
name of the column level that is used to
group the value.
Footers
TGridData
A collection of items to display summarizing
GroupFootersEh
values in groups and in general on the grid.
FootersDefValues
TGridDataGroup
The default values for the summation of
FootersDefValuesEh records.
GroupPanelVisible
Boolean
Property indicates that the panel group at the
top of the grid is visible. The panel displays
the current grouping levels. In Run-Time and
Design-Time, you can drag the panel column
headers to add to the group.
ParentColor
Boolean
Use color for color Grid of groups records.
ParentFont
Boolean
Use Font Grid to display the text of the group.
DefaultStateExpanded Boolean
Defines the opening or closing of the State
group by default when building groups
GroupRowDefValues
TGridDataGroup
Default values for the grouping of records.
RowDefValuesEh
ShiftFolldataGroupRow Boolean
Property specifies whether you want to move
the Group recording the lowest level to the
left of the data records.
Displaying summing records in groups.

In the group is allowed to display a grid summarizing the records for each group, and the overall
record summarizing the bottom of the grid.

Use a collection TDBGridEh.DataGrouping.Footers to create entries accumulating information


(footer). Each item in the collection is one entry footer. One record footers will appear in
several places in the grid. First, the record shows the footer at the bottom of the grid and
displays aggregated values across the dataset. Second, the record shows the footer of each
group. The first entry footer can be displayed in the header record of the group. The first record
for the state of the property is responsible footer DataGrouping.GroupRowDefValues.
FooterInGroupRow. When FooterInGroupRow = True Footers first item in the collection is
displayed in the header record of the group.

Each
item
in
the
collection
TDBGridEh.DataGrouping.Footers in turn, is a collection of items ReadOnly footer
corresponding to each of the columns of the grid. When you create a new collection Footer,
Footers system automatically populates a collection of Footer and the number of columns in
the grid. After creating a new Footer you must select the item if you want to specify a footer,
and an aggregate function to count. The function type is defined in the Footer.ColumnItems
[i].ValueType. ShowFunctionName property determines whether to display the values to the

left of the short name aggregation functions.RunTimeCustomizable property determines what


type of function can be changed at RunTime on the right mouse button over a cells footer.
Grid.DataGroupoing.Footers [i]: TGridDataGroupFooterEh
Property Name
Property Type
Description
Color
TColor
Specifies the background color for the footer
color.
Font
TFont
Controls the font in which the title cells
displays its data.
Visible
Boolean
Specifies whether the fotter is visible in the
grid.
ColumnItems
TGridDataGroup
Colleaction of Items for every columns. Items
FooterColumnItemsEh in the collection are created automatically
based on the list of columns.
ParentColor
Boolean
Determines where a control looks for its color
information.
ParentFont
Boolean
Determines where a control looks for its font
information.
ShowFunctionName
Boolean
Specifies whether to show the name of the
integrable function in a cell footer.
RunTimeCustomizable Boolean
Specifies that a user can change summing
function at Run-Time by mouse left button
click.

Grid.DataGrouping.Footers [i].ColumnItems [j]: TGridDataGroupFooterColumnItemEh


Property Name
Property Type
Description
Alignment
TAlignment
Specifies how text is aligned within the
footer cell.
Color
TColor
Specifies the background color for the
footer color.
DisplayFormat
string
Determines how numeric and time values
are formatted for display in a footer cell.
Font
TFont
Controls the font in which the title cells
displays its data.
ParentColor
Boolean
Determines where a control looks for its
color information.
ParentFont
Boolean
Determines where a control looks for its
font information.
ValueType
TGroupFooterValueTypeEh Summation function.
ShowFunctionName
Boolean
Specifies whether to show the name of
the integrable function in a cell footer.
RunTimeCustomizable Boolean
Specifies that a user can change summing
function at Run-Time by mouse left
button click.

The use of non-standard algorithms to calculate the aggregated values.

In the group the data grid allows to calculate the value of the elements in the footer of the
event. This allows for aggregation functions of any complexity. For each entry DataSet called
OnDataGroupFooterAggregateValue event in which to calculate the current value of the
aggregate value of the event is given for each DataSet 'entry.For example, the function sum
must be added the current field value to the counter sum
procedure TfrMailBox.DBGridEh1Columns5DataGroupFooterAggregateValue (
Grid: TCustomDBGridEh; Column: TColumnEh;
GroupFooter: TGridDataGroupFooterEh;
FooterColumnItem: TGridDataGroupFooterColumnItemEh; var AValue: Variant;
Node: TGroupDataTreeNodeEh; var Processed: Boolean);
begin
if VarIsEmpty (AValue) then
begin
AValue: = VarArrayCreate ([0,1], varInteger);
AValue [0]: = 0;
AValue [1]: = 0;
end;
if MemTableEh1post_read.AsInteger = 1
then AValue [0]: = AValue [0] + 1
else AValue [1]: = AValue [1] + 1;
Processed: = True;
end;
After all calls OnDataGroupFooterAggregateValue events for each record dataset process
causes the event the aggregate value of final settlement - ColumnEh.
OnDataGroupFooterFinalizeValue. If implemented feature requires a final step to calculate a
value, it can be done in this event.
For example, to calculate the average value of the function at the final step of the calculation
necessary to cut the sum of the number of records.
SumValue / RecordsCount
To implement this functionality, you need to calculate the variable to store two values: the sum
of the number of records.For this purpose, the calculation of the variable AValue: Variant can
make an array of two values, and in the function of the final payment, divide the first element of
the array (sum) to the second element (number).
SumValue / RecordsCount
To implement this functionality, you need to calculate the variable to store two values: the sum
of the number of records.For this purpose, the calculation of the variable AValue: Variant can
make an array of two values, and in the function of the final payment, divide the first element of
the array (sum) to the second element (number).
When the value of a cell footer display is converted a value to a text representation of
OnDataGroupFooterToDisplayText.
Events
OnDataGroupFooterAggregateValue,
OnDataGroupFooterFinalizeValue
OnDataGroupFooterToDisplayText and declared in the class and TDBGridEh TColumnEh.
Event Name/
Type
Parameter Name
OnDataGroup FooterAggregateValue

Description
Called for each record dataset. In the event
it is necessary to perform the next step of

Grid
Column
GroupFooter
FooterColumnItem
var AValue
Node
var Processed

the aggregation functions.


Grid for which to calculate the aggregated
value.
TColumnEh
The column for which to calculate the
aggregated value.
TGridDataGroupFooterEh Footer for which to calculate the
aggregated value.
TGridDataGroup
The element footer column for which the
FooterColumnItemEh
aggregated value is calculated.
Variant
The current value of the summation.
TGroupDataTreeNodeEh Tree item grouping.
Boolean
Set Processed to True, if you have
completed step sum in the event.
Otherwise, the step of summing function is
handled by default.
TCustomDBGridEh

OnDataGroupFooterFinalizeValue

Grid
Column
GroupFooter
FooterColumnItem
var AValue
var Processed

TCustomDBGridEh
TColumnEh
TGridDataGroup
FooterEh
TGridDataGroup
FooterColumnItemEh
Variant
Boolean

OnDataGroupFooterToDisplayText

Grid
Column

TCustomDBGridEh
TColumnEh

GroupFooter
FooterColumnItem

TGridDataGroupFooterEh
TGridDataGroup
FooterColumnItemEh
Variant
string
Boolean

var AValue
var DisplayValue
var Processed

Called after all calls OnDataGroup


FooterAggregateValue. In the event it is
necessary to perform the final calculation of
aggregate functions.

It is called each time when footer cell is


drawen.
Write this event to transform the internal
aggregated values to a display text value.

Using technology of summation in groups to summarize data where grouping is not


necessary.
In the grid, there are two technologies of summarizing data.

1. Summation via SumList using subproperties TDBGridEh.SumList and setup functions through
summation TColumnEh.Footer.
2. Summation via the functional grouping records when TDBGridEh.DataGrouping.Actitve =
True.
These two features are independent of each other. Configure one functionality does not affect
the other. However it is recommended to use only one feature at a time.
Summation over SumList works for any type of dataset, while grouping records only works
when plugged into the grid TMemTableEh. But adding a SumList there is a drawback concerning
data types. SumList technology keeps the total values in the variables of type Currency. Ie the
maximum number of digits after the decimal point for the summation of values = 4.
Summation by grouping records using generic type Variant, and also allows the use of nonstandard
algorithms
for
aggregation
through
events.
Summation by grouping records also allows to sum without having to create groups. To make
the sum with no groups, activate the group - DataGrouping.Active = True, the elements of the
collection to create footers - DataGrouping.Footers, but do not enable the panel grouping
DataGrouping.GroupPanelVisible = False. In this case, for each of the items in the collection will
be displayed one footer at the bottom of the grid entry.

Display graphic in grid background.


DBGridEh lets you display a static image (type TPicture) in the background of the client area of the grid.

To customize the display graphic background use BackgroundData properties


DBGridEh.BackgroundData.
DBGridEh.BackgroundData: TDBGridBackgroundDataEh
Property Name
Visible

Property Type
Boolean

Picture
Placement

TPicture
TImagePlacementEh

Description
Specifies whether the Background Pciture is visible in
the grid.
The Pciture to draw as a Background Data.
Specifies the position of the image and the way of
filling the free space
TImagePlacementEh = (
ipTopLeftEh,
ipTopCenterEh,
ipTopRightEh,
ipCenterLeftEh,
ipCenterCenterEh,
ipCenterRightEh,

HorzMargin
VertMargin
ExcludeTitle
ExcludeIndicator
ExcludeFooter

Integer
Integer
Boolean
Boolean
Boolean

ipBottomLeftEh,
ipBottomCenterEh,
ipBottomRightEh,
ipFillEh,
ipFitEh,
ipStretchEh,
ipTileEh);
Horizontal Shift
Vertical Shift
Delete the title of the fill graphic background.
Delete button from the fill graphic background.
Delete the footer of the fill graphic background.

Searching Data in the Grid.


DBGridEh allows you to perform the following types of search data:
Dialog search With the help of a special window Dialogue.
To allow interactive search grid,
set dghDialogFind value In
TDBGridEh.OptionsEh property.
At Run-Time Use the Ctrl+F key
combination to show the
search dialog.
To run the program from the dialog box, use the procedure module DBGridEhFindDlgs:
procedure ExecuteDBGridEhFindDialog(Grid: TCustomDBGridEh; Text,
FieldName: String; ColumnFields: TColumnFieldsArrEh; Modal: Boolean);

You can override the global method of assigning a dialog box pointer to the global
process
var
ExecuteDBGridEhFindDialogProc: TExecuteDBGridEhFindDialogProc;

You can redefine the key combination to display the dialog box by assigning a new
combination of a global variable DBGridEhFindDialogKey: TShortCut. The variable
declared in the module DBGridEh.

Incremental search in the column Search while typing in the column grid.
TDBGridEh allows users to make a special "incremental" searches column grid. When
the user enters an incremental search, he can type characters. This grid will tries to find
typed text in the current column. Use dghIncSearch and dghPreferIncSearch values
(property OptionsEh) for controlling an incremental search. At runtime, you can use the
following keyboard shortcuts for incremental search:
Ctrl+F - start incremental search.
Ctrl+Enter - Find next match.

Ctrl+Shift+Enter - Find previous match.


If dghIncSearch included OptionsEh and column - read-only, then the grid includes an
incremental search automatically the first time the key is pressed and will be returned
to normal after 1.5 seconds. dghPreferIncSearch value determines that the grid will set
increment search mode automatically when the first key is pressed instead of editing.
To use the incremental search in the code use the following methods:
procedure TCustomDBGridEh.StartInplaceSearch(const ss: String;
TimeOut: Integer; InpsDirection: TLocateTextDirectionEh);
Starts Incremental search and searches for the string passed. Ss parameter
contains the search string. TimeOut parameter contains the period in
milliseconds after which an incremental search is automatically stopped.
InpsDirection parameter specifies the search direction.
procedure TCustomDBGridEh.StopInplaceSearch;
The method stops incremental search mode.
TDBGridEh allows users to accomplish a special "increment" search in grid columns. When user
enter in increment search mode, he can type chars and grid will try to locate text in the current
column. Use dghIncSearch and dghPreferIncSearch values (OptionsEh property) to customize
increment search in the grid. dghIncSearch value allows to perform incremental search in grid.
At run time you can use next keys for incremental searching:
Ctrl+F - to begin increment searching.
Ctrl+Enter - to search next matching.
Ctrl+Shift+Enter - to search prior matching.
If dghIncSearch in OptionsEh and column is read only then grid will enter in increment search
mode automatically after first key press and will return to normal mode after 1.5 sec.
dghPreferIncSearch value determines that the grid will set increment search mode
automatically after first key press instead of cell editing.
Search through the search panel Search using a special panel contain text editor where user
type the text to search for. Read the detail in the next section.

Search panel and filter data.


DBGridEh can display a special panel to search and filter the data in the grid.

In search mode, grid displays the search


phrase in all grid cells in a different color (yellow by default).Grid also allows you to filter the data so
that the screen will display only those records that include the search string.
To configure the settings
DBGridEh.SearchPanel.

panel,

search

and

filter

properties

using

sub-properties

DBGridEh.SearchPanel: TDBGridSearchPanelEh
Sub-properties properties TDBGridEh.Border:
Property Name
Enabled

Property Type
Boolean

Description
Set the Enabled property to True to activate the
search and filter of the panel. Activate the Panel still
does not mean that it will be immediately visible in
the grid. Panel's visibility is set through property
PersistentShowing.
PersistentShowing Boolean
Specifies that the search panel always visible in the
grid. If PersistentShowing = False, the panel
becomes visible after pressing the key combination
to activate the search through the panel in the
property ShortCut.
ShortCut
TShortCut
Specifies the key combination to activate the search
panel and give focus to the input text editor search
bar. Defaults to "Ctrl + F".
Location
TSearchPanelLocationEh Location of the search panel. Can take the following
values:
splGridTopEh - Search panel at the top of the
grid above the title.
splHorzScrollBarExtraPanelEh - Search panel is
in the "extra-bar" thumb scroll horizontally.
The search panel works correctly in this
location, "extra-panel" slider is visible.
splExternal - Search panel is outside the grid.
In this mode, the algorithm of the search
panel and drawing the sole responsibility of
the developer.
FilterOnTyping
Boolean
Specifies that the grid will filter data as you enter
text in the text editor panel of the search. If
FilterOnTyping = False then the data will be filtered
only by pressing the key Enter or click the Apply
Filter button in the search panel.
FilterEnabled
Boolean
Specifies that filter is available in the search panel.

If FilterOnTyping = False, then the search will only


be available by code.

TDBGridEh and vertical scrollbar.


If you work with different types of dataset you can notice that for some types of dataset the
DBGrid shows vertical scrollbar correctly, but for other dataset their vertical scrollbar has only
three positions independently of record count in dataset. To adjust the vertical scrollbar
accommodation the DBGrid uses RecordCount and RecNo property of DataSet component. But
some dataset holds -1 in RecordCount and RecNo. DataSet function IsSequenced indicates
whether the underlying database table uses record numbers to indicate the order of records.
When IsSequenced returns True value, applications can safely use the RecNo property to
navigate through records in the dataset and DBGrid can use RecNo property to show thumb
position in vertical scrollbar. But when IsSequenced returns False value, DBGrid can not define
current record position and it shows vertical scrollbar in three positions. DBGridEh component
has possibility to show proportional scrollbar for no sequenced dataset. To do it we need to
activate SumList and create list of record bookmars. Set SumList.Active to True and
SumList.VirtualRecords to True. SumList will run through dataset and create list of records
bookmarks. If you use client/sever technology to access database SumList will force dataset to
fetch all records, but this operation can take much time. Keep in mind that VirtualRecords will
work only for full relationship bookmarks dataset, it means that DataSet.ComapreBookmark
function has to return > 0 if record1 is after record2 (i.e. record to which bookmark1 indicates
has to be after record to which bookmark2 indicates). It must return 0 if bookmark1 and
bookmark2 points to the same record, and value < 0 if record1 is before record2. TBDEDataSet
in most cases support full relationship bookmarks.

Customizing scrollbars.
You can control the horizontal and vertical scrolling bar
using the Grid.VertScrollBar and Grid.HorzScrollBar
properties of TGridScrollBarEh type.
The TGridScrollBarEh class contains the following
properties:

Property Name

Property Type

Description

Tracking

Boolean

Specifies whether or not the position in the grid to


change immediately when user change the position of
the slider when the user clicked the mouse and drags
the slider.

Visible

Boolean

Specifies permanent visibility slider bar. (The property


is out of date, use VisibleMode)

SmoothStep

Boolean

Sets the scroll step of the grid in which the grid is not
specified on the border of the cell, and pixel-by-pixel.
When SmoothStep, the grid visually scroll more

smoothly, with the end of the scroll bar does not


guarantee that the left-top cell of the grid will start at
the border of the visible area of the grid. SmoothStep
mode only works when the grid is bind to the DataSet
of TMemTableEh type.
VisibleMode

TScrollBarVisibleModeEh

Sets the scrollbar show mode:


sbAlwaysShowEh - the scroll bar is always displayed.
sbNeverShowEh - scroll bar is always hidden.
sbAutoShowEh - the scroll bar is displayed only if the
grid is not reduced in the visible area of the client
window.

Height

Integer

For the horizontal scroll bar sets the height of the


strip. For vertical property is not available.

Width

Integer

For the vertical scroll bar sets the width of the strip.
For horizontal scroll feature is not available.

ExtraPanel

TDBGridEhScrollBarPanel

The property is available only for horizontal stripes.


The property specifies the parameters of the
additional panel that is displayed in the left part of the
band. A detailed description, see the next section.

To customize scollbars you need to use subprtoperties of HorzScrollBar and VertScrollBar


properties.
Tracking: Boolean
This property
SmoothStep: Boolean

ExtScrollBar: TScrollBar;

Visible: Boolean;

VisibleMode: TScrollBarVisibleModeEh;
sbAlwaysShowEh
Always shows scrollbar.
sbNeverShowEh
Never shows scrollbar.
sbAutoShowEh
Shows or hides scrollbar automatically
depending on visible area of grid.
If grid is connected to DataSet of TMemTableEh type then on vertical scrolling grid doesnt
change position of active record.

Extra horizontal scroll bar slider (ScrollBar).


DBGridEh allows displaying additional information in the horizontal scrolling section. In this case, the left
side of the SrollBar is moved to the right so as to display information.

Area of additional information may include the following:


The number of entries in the DataSet and the number of selected records in a grid.
Navigation buttons on records (DBNavigator).
Search bar and filtering (SearchPanel).
Summary information about the selected data (MultiSelected area). Data section will be
visible when the user selects a region in the grid, square area or column. In this case, in the
summary information is displayed: The amount of data, number of selected rows, average,
minimum and maximum value

Use the sub-property DBGridEh.HorzScrollBar.ExtraPanel management options to display


extra panel:
Property Name
Visible

Property Type
Boolean

NavigatorButtons

TNavButtonSetEh

VisibleItems

TGridSBItemsEh

Description
Set the Visible property to True to display additional
panel horizontal ScrollBar
Use the NavigatorButtons property to determine
which navigation buttons will be visible in the
database navigator.
TNavigateBtnEh = (nbFirstEh, nbPriorEh,
nbNextEh, nbLastEh, nbInsertEh,
nbDeleteEh, nbEditEh, nbPostEh,
nbCancelEh, nbRefreshEh);
TNavButtonSetEh = set of TNavigateBtnEh;
Use VisibleItems property to determine which items
will be visible in the panel.
TGridSBItemEh = (gsbiRecordsInfoEh,
gsbiNavigator, gsbiFindEditorEh,
gsbiSelAggregationInfoEh);
TGridSBItemsEh = set of TGridSBItemEh;

Displaying the search for extra-panel runner is configured through the properties of the search bar
Grid.SearchPanel.
Clicking on the navigation button event fires NavigatorPanelButtonClick event. The event is passed the
type of button AButton: TNavigateBtnEh. In the event handler, you can set the Processed parameter
to True to avoid calling of the default handler.

Flexible adjustment of color and the presence of the border of the


client area Grid.

DBGridEh allows you to customize the color and display side border (Border) of the client area Grid.
Sub-properties of property TDBGridEh.Border:
Property Name
Color
Ctl3D

Property Type
Boolean
Boolean

EdgeBorders

TEdgeBorders

ExtendedDraw

Boolean

Style

TBorderStyle

Description
Background color fringing.
Specifies that the line shall be drawn in 3D. Top and
left border darker color. Bottom and right lighter.
EdgeBorders property is set (set) that indicates which
side of border drawn. A set can contain a combination
of the following - ebLeft, ebTop, ebRight, ebBottom.
Use ExtendedDraw property to establish that border
will be drawn through the inner grid instead by
standard features of the functional Windows.
Color properties and EdgeBorders are taken into
account only when ExtendedDraw = True.
Style edging. It can take values bsNone and bsSingle.

New event TColumnEh.OnGetHideDuplicatesValue to indicate


accurately when to hide duplicate values.
Column property TColumnEh.HideDuplicates customizes the display of the column so as to hide the
value in the cell if it matches the value in the previous record.
There are situations when it is necessary to point out that actually started a new value in the cell, even if
the text representation of the values matched. For example: User names can be the same, but user ID is
not same. Accordingly, the same name with different IDs are not duplicates.
Use OnGetHideDuplicatesValueKeyValue event assign KeyValue parameter the value that identify
unique value for every new display value of the column.
procedure TForm1.DBGridEh1Columns3GetHideDuplicatesValue (
Sender: TCustomDBGridEh; Column: TColumnEh; var KeyValue: Variant);
begin
KeyValue: = MemTableEh1 ['EmpNo'];

end;

Demo:
folder

See the Demo project to use OnGetHideDuplicatesValue event in the


<EhLib Dir\Demos\ DBGridEh.HideDuplicates>

Filtering data in drop-down lookup lists when typing.


In components TDBLookupComboboxEh and TColumnEh when the grid is connected to a field
in a column of type Lookup has the ability to filter the data set from the drop-down lookup list
when the data set in the lookup text editor.
In normal operation, the lookup text editor as you type with the keyboard software in the
dropdown lookup list automatically goes to the entry that starts the typed text.
In the additional filtering of text, the program further filters the data so that the list are only the
records that satisfy the typing.
Filtering can operate in two modes (lsftBeginsWithEh and lsftContainsEh):

While lsftBeginsWithEh, the program displays only those records where the beginning of the
text in the list coincides with the beginning of the text in the editor. In this example, the list will
show all records that have a company name begins with Un. As you type, the number of
entries in the list is reduced.

While lsftContainsEh program displays only records that have the typed text is in any position
of the first column of the combo box. In this case, the found text is highlighted in color.
To filter the data in drop-down lists to lookup:
- Assign property DropDownBox.ListSource (TColumnEh. DropDownBox.ListSource or
DBLookupComboboxEh.DropDownBox.ListSource). DropDownBox.ListSource must refer to the
DataSource which DataSource.DataSet a separate DataSet that will filter the data. Filtering is
done through the property DataSet.Filter: = '[FieldsName] Like abc *' or '* abc *' depending on
the mode (lsftBeginsWithEh and lsftContainsEh). As an icon substitution Wildcard default is '*'.
If your DataSet supports different icon for Wildcard Like expressions, you must register the
class derived from TSQLDatasetFeaturesEh where overloaded virtual function
GetLikeWildcardForSeveralCharacters. Standard datasets such as TADODataSet, TClientDataSet,
etc. Such classes are already written and recorded automatically if the partition uses any design

unit prescribe the appropriate module EhLibXXX (EhLibADO, EhLibCDS, etc.) in the same way as
for setting sorting and filtering in the grid.
- Enable filtering typing: DropDownBox.ListSourceAutoFilter = True.
- Set the mode filtering: DropDownBox.ListSourceAutoFilterType = lsftBeginsWithEh or
DropDownBox.ListSourceAutoFilterType = lsftContainsEh.

Using DBGridEh for sorting and filtering data in the DataSet.


DBGridEh can not sort or filter data by itself. But it can pass action for sorting or filtering to the
specal object that will do it in DataSet. You can adjust grid for two types of sorting (local or
server), using property SortLocal and two type of filtering (also, local and server), but real
possibility to apply each type of operation depends on the type of DataSet. For instance,
TBDEDataSet does not suppot sorting locally (inside DataSet). so you can not sort data locally
when grid is linked to TQuery or TTable. Furthermore, EhLib has only special objects for
standard types of DataSet (not for a third party DataSet's).
Below you can see a table of special object and DataSet in which those objects can sort or filter
data.
Unit

DataSet

Local sorting

Server sorting

Local filtering

Server filtering

EhLibBDE

TQuery,
N
Y
Y
Y
TTable
EhLibADO
TADOQuery,
Y
Y
Y
Y
TADODataSet
EhLibCDS
TClientDataSet
Y
Y
Y
Y
EhLibDBX
TSQLQuery,
N
Y
N
Y
TSQLDataSet
EhLibIBX
TIBQuery,
N
Y
Y
Y
TIBDataSet
EhLibMTE
TMemTableEh
Y
Y*
Y
Y*
* If Grid is configured for Server sorting of Filtering (SortLocal=False, STFilter.Local=False), then
sort operation is transferred to the TMemTableEh.DataDriver object.
When grid is adjusted for a local filtering, the special object will build expression and assign it to
a property Filter of DataSet. So we need also to set Filtered to True value manually.
When grid is adjusted for a server filtering, the special object will build SQL:ORDER BY
expression and it will replace ORDER BY string in SQL or Command property of DataSet and it
will reopen DataSet.
When grid is adjusted for a local sorting, the special object will perform a sorting using
specific type of DataSet.
When the grid is adjusted for a server sorting, the special object will build expression for SQL
'WHERE' clause in SQL string of dataset. It will try to find string that begins from key string
'/*Filter*/' in SQL expression and adds filter expression after this string in same line (You can
change this key string using global variable - SQLFilterMarker) . So your SQL query must have a
line that begins from '/*Filter*/'. For instance:
' select *
from table1
where
/*Filter*/ 1=1 '

For automatically filtering/sorting data in dataset you need to add one of the units EhLibXXX
(EhLibADO, EhLibBDE, EhLibCDS ... depend on the type of dataset where the grid is linked to) to
'uses' clause of any unit of your project. This units have code to register TDatasetFeaturesEh
based classes (special object) for respective DataSet's. For other third party DataSet's you have
to write and register your own special object or you have to write OnApplyFilter or/and
OnSortMarkingChanged events for every required grid. Moreover, you can write
OnApplySorting and/or OnApplyFilter for the global variable DBGridEhDataService. These
events have TNotifyEvent type where Sender is TCustomDBGridEh.

Adjusting grid for sorting data:


TDBGridEh allows showing special sortmarking bitmaps (small triangles) in the right part of title
cell. In order to automatically mark the title by sortmarking bitmaps you have to add
dghAutoSortMarking to OptionsEh property. Add dghMultiSortMarking to OptionsEh in order to
allow sortmarking in several columns simultaneously. Set Column.Title.TitleButton to true value
for titles which will have possibility to change sortmarkers at run time. Or you can set
ColumnDefValues.Title.TitleButton to allow setting sortmarking for all columns where
Column.Title.TitleButton is not changed. At runtime, clicking on title will change sortmarking.
Holding Ctrl key allows to mark several columns simultaneously. After user changes sormarking
grid will call OnSortMarkingChanged event or will pass action to special object, if it is registered.
Special object will use Grid.SortLocal property to determine how to sort data: locally or on the
server. If you write OnSortMarkingChanged, you can use TDBGrid.SortMarkedColumns property
to access the sortmarked columns and TColumnEh.Title.SortMarker property to get state of the
sortmarker.

Adjusting grid for filtering data:


TDBGridEh allows to show special row (under title) where user enters expressions in cells for
filtering records in dataset.

(Expression in the cell can look like: "1", ">=1", ">1 AND <=5", "%TestStr%"). Set STFilter.Visible
to True value to show this special row. AT Run time, when cursor locate in the filter cell, they
can press ENTER to apply filter. Grid will parse expression in every not empty filter cell and call
TDBGridEh.ApplyFilter. And it calls OnApplyFilter event or passes action to special object, if it is
registered.
For normally parsing, the expression in cell have to have next format:
[Operator1] Operand1 [)] [AND|OR Operator2 Operand2 [)] ]
Where OperatorX is one of [ = | <> | != | > | < | >= | <= | ~ | !~ | in ( ]
OperandX is a numeric, date or string value or for the operator 'IN' it is a list of values divided
by comma.
For instance:
'1'
'>=1'
'>1 AND <=5'

'~ TestStr%'
'!~ TestStr_'
'in (1,2,3,4,5,6) and >100'
'in (Str1,Str2,Str3)'
Grid allows to show dropped down list of STFilter in title cells. Set STFilter.Location to
stflInTitleFilterEh to active this mode. Use item (Custom) to enter string for filtering or press
checkboxes above required values. Global variable DBGridEhShowInTitleFilterBox contain key
combination for opening list of filtering values. By default it contains 'Ctrl-T'.

When grid is connected to the list of uncial values of column is formed automatically. In
addition, list is formed with tacking in account of filter applied in other columns. To form list of
values and command for filtering, use next events and methods: Events TDBGridEh.OnFillSTFilterListValues,
TColumnEh.OnFillSTFilterListValues,
TDBGridEhCenter.OnFillSTFilterListValues
or
rewrite
method
TDatasetFeaturesEh.FillSTFilterListDataValues and register new class MyDatasetFeaturesEh for
interaction between grid and dataset.
Grid call event OnFillSTFilterListValues every time when it is needed to fill list of StFilter, that have
next type:
TDBGridEhFillSTFilterListValuesEvent = procedure(Sender: TCustomDBGridEh; Column: TColumnEh; Items:
TStrings; var Processed: Boolean) of object;

This event presents in TDBGridEh, TColumnEh, TDBGridEhCenter.


Every item of Items list must consists of two values: String - Items[i] and Object
Items.Objects[i]. Items of object type must be inherited from TPopupListboxItemEh type and they
must be declared as global variables. There are already next global variables in DBGridEh:
PopupListboxItemEhSortAsc: TPopupListboxItemEhSort;

Item of the list show sorting item Asc and executes sorting in ascending order.
PopupListboxItemEhSortDes: TPopupListboxItemEhSort;

Item of the list show sorting item Asc and executes sorting in descending order.
PopupListboxItemEhLine: TPopupListboxItemEhLine;

Item of the list show horizontal line. On choosing doesn't perform any actions.
PopupListboxItemEhClearFilter: TPopupListboxItemEhSpec;
PopupListboxItemEhAll: TPopupListboxItemEhSpec;
PopupListboxItemEhEmpties: TPopupListboxItemEhSpec;
PopupListboxItemEhNotEmties: TPopupListboxItemEhSpec;
PopupListboxItemEhDialog: TPopupListboxItemEhSpec;
PopupListboxItemEhApplyFilter: TPopupListboxItemEhSpec;

PopupListboxItemEhData: TPopupListboxItemEhData;

Item of the list shows text that defines text of filtering. When it is selected, it is checked
by checkbox and it is put in the list of items of values that is needed be in the filtered
records.
You can call next methods in the event to fill values by default
TDBGridEh.DefaultFillSTFilterListValues(Column: TColumnEh; Items: TStrings)
TDBGridEh.DefaultFillSTFilterListCommandValues(Column: TColumnEh; Items: TStrings)
TDBGridEh.DefaultFillSTFilterListDataValues (Column: TColumnEh; Items: TStrings)

Next code show OnSTFilterListValues event where sorting items is deleted from list:
procedure TForm1.DBGridEh1FillSTFilterListValues(Sender: TCustomDBGridEh;
Column: TColumnEh; Items: TStrings; var Processed: Boolean);
var
Index: Integer;
begin
Sender.DefaultFillSTFilterListValues(Column, Items);
Index := Items.IndexOfObject(PopupListboxItemEhSortAsc);
if Index >= 0 then
Items.Delete(Index);
Index := Items.IndexOfObject(PopupListboxItemEhSortDes);
if Index >= 0 then
Items.Delete(Index);
Processed := True;
end;

Now library can fill list of unical values only for DataSet of TMemTableEh type. To fill values
when grid is connected to other type of
DataSet, it is required rewrite
TDatasetFeaturesEh.FillSTFilterListDataValues method and , if it is need, it is required to register
class that inherited from TDatasetFeaturesEh. Read information about TDatasetFeaturesEh
class in EhLib users guide and EhLibMTE.Pas.
New
properties
STFilterDefaultStringOperator,
STFilterDefaultNumberOperator,
STFilterDefaultDateTimeOperator,
STFilterDefaultBooleanOperator
are
added
in
TDBGridEhCenter class.
Use this properties to set default operator that will be used when
string in the STFilter doesn't containt operator. The operators can be assigend appart for String
fields, Numeric fields, DataTime fields and logical fields.

Customizing grid title.


Use the sub-properties of property TDBGridEh.TitleParams to adjust display the column
grid.
Sub-properties of property TDBGridEh.TitleParams:
Property Name
Color

Property Type
TColor

Description
Specifies the background color for the title cells.

Font

TFont

ParentFont

Boolean

SecondColor

TColor

Images

TCustomImageList

MultiTitle

Boolean

RowHeight
RowLines

Integer
Integer

SortMarkerStyle
VTitleMargin

TSortMarkerStyleEh
Integer

VertLineColor
VertLines
HorzLineColor
HorzLines
FillStyle
BorderInFillStyle

TColor
Boolean
TColor
Boolean
TGridCellFillStyleEh
Boolean

Controls the font in which the title cells displays its


data.
Determines where a control looks for its font
information.
Second background color that is used when cells
painted in gradient mode. Use FillStyle property to
define paint style.
List of Images when displaying images in the header.
Index of drawing Image is defined in
Column.Title.ImageIndex
Determines that the title will be drawn in a MultiTitle
mode.
Specifies the height of data row in text lines
Specifies the height of data row in text lines
Full row height = height in pixels of RowLines +
RowHeight.
Defines the shape of the sorting markers.
Specifies the margin between text and bottom of title;
and margin between text and top of title.
Color vertical lines in the data area.
Presence of vertical lines in the data area.
Color of the horizontal lines in the data area.
Presence of horizontal lines in the data area.
Specifies the style of filling the title cells.
Specifies that the vertical lines are drawn by the
function that draw header cell rather then function
that draw cell lines. In this mode vertical lines are
drawn not to the end of the border crossing.

Complex titles.
TDBGridEh allows to create one common title above several columns. See Figure:
To do it, set DBGridEh.UseMultiTitle property to True value and fill label of the fields or caption
of column title using next rule: every part of text in field label or column title must consist of
several parts divided by sign "|", where every common part must be same for several required
columns. Other fields or captions must contain same text
in the corresponding parts.
For example:
Field1.DisplayLabel := 'Title1|SubTitle1';
Field2.DisplayLabel := 'Title1|SubTitle2';

or
DBGridEh.Columns[0].Title.Caption := 'Title1|SubTitle1';
DBGridEh.Columns[1].Title.Caption := 'Title1|SubTitle2';

Title acts as a button.


Set Column.Title.TitleButton to True to make title cells act as a button. You can also write an
OnTitleBtnClick event to take specific action when the user clicks on title cell.

Show bitmaps in titles.

Use TitleImages property of TDBGridEh and ImageIndex property of TcolumnTitleEh to show


bitmap in titles instead of caption.

Sorting markers
Change the sort order for the marker sorting. In the new version make the p-triangle sorting pointing
down means sorting type DESC (from highest to lowest). The first sort direction is determined by the
type of field. For text fields, the first sort order is set to high for the rest of the fields in descending
order. To change the direction of the first rewrite virtual function use
TDBGridEhCenter.GetFirstSortMarkerState. To install the new center Grids use the global
function SetDBGridEhCenter.
You can set the icon sorting through properties TDBGridEh.TitleParams. SortMarkerStyle for a
particular grid or through global property DBGridEhDefaultStyle.SortMarkerStyle.
type TSortMarkerStyleEh:
smstDefaultEh
- Use steel default defined in
DBGridEhDefaultStyle.SortMarkerStyle
smstClassicEh
smst3DFrameEh
smstFrameEh
smstSolidEh
smstThemeDefinedEh

Customizing Indicator column.


The Indicator Column is usually shown at the very left part of the Grid and is colored in
red color (The color varieties depending of current color scheme in the Windows). The
Indicator Column can display such information as: Indicator of the current record (Is
shown as triangular), State of editing, the number of the current record and checkbox
of selected record. Use properties of TDBGridEh.IndicatorOptions property to
customize the Indicator Column.
TDBGridEhIndicatorOptions = set of TDBGridEhIndicatorOption;
TDBGridEhIndicatorOption = (gioShowRowIndicatorEh, gioShowRecNoEh,
gioShowRowselCheckboxesEh);
gioShowRowIndicatorEh Display indicator of current record in the indicator column.
gioShowRecNoEh Display the number of the current record in the indicator column. This
property works only for DataSets that support IsSequenced mode (See Help about
TDataSet.IsSequenced).
gioShowRowselCheckboxesEh Display checkbox of selected record. At runtime, user can
select records by clicking on checkboxes. Bookmarks of selected records are stored in the
TDBGridEh.SelectedRows or TDBGridEh.Selection.Rows collection.

Use the sub-properties of property TDBGridEh.IndicatorParams and to customize the


display of the indicator column.
Property Name
Color
HorzLineColor
HorzLines
VertLineColor
VertLines
FillStyle
RecNoShowStep

Property Type
TColor
TColor
Boolean
TColor
Boolean
TGridCellFillStyleEh
Integer

Description
Specifies the background color for the indicator color.
Color of the horizontal lines in the data area.
Presence of horizontal lines in the data area.
Color vertical lines in the data area.
Presence of vertical lines in the data area.
Specifies the style of filling the indicator cells.
If set to gioShowRecNoEh IndicatorOptions (Also the
same as in dghShowRecNo OptionsEh), then this
property specifies step with which to show record
numbers in the column display. For records that fall
between steps, the record number is displayed
instead of a point. This eliminates the effect of
"flickering" numbers, which can occur when displaying
each record number.

Customizing grid footer.


Footers and total values.
TDBGridEh can display special row (footer) or rows at bottom part. Use FooterRowCount
property to specify the number of footer rows in the grid. Use Footer or Footers property of
TColumnEh object to specify information which needs to show in footer cells. Footers property
is useful when you have more than one footer rows. Footers are a collection of
TColumnFooterEh objects. Information from i-th element of collection will be shown in i-th row
of footer. In footer cell, it is possible to show: Sum value for the specific field, records count,
the value of a specific field or static text. Use property Footer.ValueType or
Footers[i].ValueType to specify which type of value will be shown in the footer cell. If
ValueType = fvtStaticText, then you also need to set Value property to specify text which will be
shown. If ValueType = fvtFieldValue, then you need to set property FieldName to specify the
field, value of which will be shown. To force grid to calculate total values you need to activate
SumList (Set DBGridEh.SumList.Active to True value).
Set TColumnFooterEh.ValueType to fvtSum to show sum value of the column field in the footer
cell, you can also specify Column.Footer.FieldName to calculate total value of the other field.
Set ValueType to fvtCount to force grid to display count of records in the footer cell.
Use the sub-properties of property TDBGridEh.FooterParams to Customize the footer of
the grid.
Property Name
Color
FillStyle
Font

Property Type
TColor
TGridCellFillStyleEh
TFont

ParentFont

Boolean

Description
Specifies the background color for the footer color.
Specifies the style of filling the footer cells.
Controls the font in which the title cells displays its
data.
Determines where a control looks for its font

RowHeight
RowLines

Integer
Integer

HorzLineColor
HorzLines
VertLineColor
VertLines

TColor
Boolean
TColor
Boolean

information.
Specifies the height of footer row in text lines
Specifies the height of footer row in text lines
Full row height = height in pixels of RowLines +
RowHeight.
Color of the horizontal lines in the footer area.
Presence of horizontal lines in the footer area.
Color vertical lines in the footer area.
Presence of vertical lines in the footer area.

The SumList property includes the following subproperties:


Property Name

Property Type

Description

Active

Boolean

Set this property to activate the object SumList.


SumList used to calculate aggregate values in the
footer of the grid.

ExternalRecalc

Boolean

The property specifies that the summation is an


external method implemented in the
DBGridEh.OnSumListRecalcAll event handler.

VirtualRecords

Boolean

Set this property to True to correctly calculate the


positions of the vertical scrollbars for datasets that do
not support or incorrectly returns the number of
records through the property DataSet.RecNo.

DBGridEh events, related to the calculation of aggregate values in SumList'e:


OnSumListRecalcAll The event is called when DBGridEh.SumList.ExternalRecalc = True. In
the event handler is necessary to calculate the aggregate amount for the items in the collection
and fill DBGridEh.SumList.SumCollection value DBGridEh.SumList.SumCollection [i] .SumValue.
OnSumListAfterRecalcAll The event is called after counting all aggregated values
through SumList.
TColumnEh.Footer and TSolumnEh.Footers[i] elements have TColumnFooterEh type and
contain the following properties:
Property Name

Property Type

Description

Alignment

TAlignment

Alignment of a summed value in the cell footer.

Color

TColor

Color of a cell footer.

DisplayFormat

String

The format for displaying numbers

EndEllipsis

Boolean

Display ellipsis if text does not fit in a cell grid

FieldName

String

Name of the field to which it applies the aggregate


function of certain properties ValueType

Font

TFont

Font of a cell footer

ToolTips

Boolean

Whether to display the tooltip window with a full text


of the cell when user move the mouse on footer cell if
the text does not fit into the cell.

Value

String

Static text that is displayed in the cell when a


Footer.ValueType = fvtStaticText

ValueType

TFooterValueType

Type of output value, or summing function. The


property may comprise the following values:
fvtNon, fvtSum, fvtAvg, fvtCount, fvtFieldValue,
fvtStaticText

WordWrap

Boolean

Wrap text, if it does not fit on one line in a footer cell.

Use DBGridEh.OnGetFooterParams event in order to control the parameters of the cell footer
draw operation.
procedure TForm2.DBGridEh2GetFooterParams(Sender: TObject; DataCol,
Row: Integer; Column: TColumnEh; AFont: TFont; var Background: TColor;
var Alignment: TAlignment; State: TGridDrawState; var Text: string);
begin
end;

In the event you can change property values AFont, Background, Alignment, Text to change the
text and text fortmat footer cell before rendering.
Use the following methods and properties when using the footer:
function
TDBGridEh.GetFooterValue(Row:
Integer;
Column:
TColumnEh): String;
The method returns a string value in the footer for a column definition.
Parameter Row sets the row number footer (FooterRowCount be more than 1).
Column specifies the column for which it is necessary to obtain the value of the
footer.

Hints and Tooltips


Hints and Tooltips are special text hints, which are shown in small additional window (usually in
a yellow color) while the mouse is above a specified place of grid. To show Hints and Tooltips in
DBGridEh it is required to set ShowHint property to True. Hints usually contain additional
information about a data in the cell. Tooltips usually contain a full-text of cell if it doesnt fit in
the cell. To show Tooltips in DBGridEh, use the Column.ToolTips, Column.Title.ToolTips, and
Column.Footer.ToolTips properties. Besides, there are events Column.OnDataHintShow and
Column.DBGridEh that allow to form Hints for cell dynamically. Use these events to set Text,
Font, Colour, Position or the other parameters of hint window for every cell of the grid. These
events will be called only if Grid.ShowHint is set in True. During the calling event the grid is
positioned on required record. So you can access fields values from dataset.
Hint and Tooltips are special text prompts that appear in a small additional window (usually
yellow) when you hover over a specific area of the window. To enable Hint and Tooltips in
DBGridEh you need to set DBGridEh.ShowHint property to True.
In the Hint, it is usually displayed additional information.
In Tooltips it is usually displayed the full text, which is not fully fit in the cell data and cropped
when drawing.
To display Tooltips'ov DBGridEh use in the following properties properties:

property DBGridEh.ShowHint: Boolean Show hints and Tooltips in the grid.


property Column.ToolTips: Boolean Show tooltips in the column data cells.
property Column.Title.ToolTips: Boolean Show tooltips in the column header.
property Column.Title.Hint: String Hint text for the column header.
property Column.Footer.ToolTips: Boolean Show tooltips in the column footer cell.
property DBGridEh.ColumnDefValues.ToolTips: Boolean Show tooltips in the
cells of all the data column grid.
property DBGridEh.ColumnDefValues.Title.ToolTips: Boolean Show tooltips
titles of all columns grid.
You can use the Column.OnDataHintShow or DBGridEh.OnDataHintShow event for dynamic
formation of Hint or Tooltipos for data cells. Use these events to set the text font, color,
position or other parameters of the info window (hint) for each cell in the column grid. These
events will be called only if Grid.ShowHint set to True. At the time of the call event grid will set
the current record in the dataset according to the number of grid lines, so that you can access
data record. You can call the method for standard event processing
DBGridEh.DefaultFillDataHintShowInfo.
You can use the Column.OnHintShowPause or DBGridEh.OnHintShowPause event to determine
the delay before displaying the hint. In the event handler, you must set HintPause to the delay
in milliseconds, that must elapse before displaying tips. If you set HintPause, it also set the
Processed to True to avoid causing method for standard event processing.

Customize the SubtitleFilter filtering columns.


Use the sub-properties of property TDBGridEh.STFilter to customize the display area of the filter data by
columns (called Subtitle Filter). This is usually a separate line just under the heading Grid. However, you
can configure this field so that it appears in the header as a button drop-down list. In version 6, the
opportunity to customize the color of cells dividing lines color, font and icon display mode drop-down
list.
TDBGridEh.STFilter
Property Name
InstantApply

Property Type
Boolean

Local

Boolean

Location

TSTFilterLocationEh

Visible
Color
Font

Boolean
TColor
TFont

ParentFont

Boolean

Description
Defines if filter will be applied on chanching or clising
of droped down list of filtered values (STFilter)
Grid does not use it, but object that perform filtering
can determine whether it will filter locally in dataset
or on the server (by adding filter expressions in SQL
'WHERE' clause)
Defines the location STFilter. Under the title
(stflUnderTitleFilterEh) or in the title
(stflInTitleFilterEh). When in the title then STFilter
doesn't support edit line to enter filter expression.
Specifies whether the filter row is visible.
Specifies the background color for the title cells.
Controls the font in which the title cells displays its
data.
Determines where a control looks for its font

HorzLineColor
RowHeight
RowLines

TColor
Integer
Integer

VertLineColor
TColor
FilterButtonDrawTime TDBGridFilter
ButtonDrawTimeEh

information.
Color of the horizontal lines in the footer area.
Specifies the height of footer row in text lines.
Specifies the height of footer row in text lines
Full row height = height in pixels of RowLines +
RowHeight.
Color vertical lines in the footer area.
Specifies when it is to draw buttons for DropedDown
filter list.

Drawing information about the absence of records in a dataset.


Grid allows to show special text in the central part of client area about absence of records in a
dataset. If the DataSet is active and havent any record then grid will draw text <No Records>.
Use
subproperies
of
TDBGridEh.EmptyDataInfo property to
customize Text and Font of this information.
By default the text about absence of
records is taken from global constant
SNoData. You can set Text for every Grid
using
TDBGridEh.EmptyDataInfo.Text
property or set global variable DBGridEhEmptyDataInfoText from DBGridEh unit.

Setting the display of tree records


DBGridEh allows you to customize the icons displayed in the grid in tree mode (When MemTable keeps
records in a tree view). To customize the display of the icons of the tree, use sub-properties of property
TDBGridEh.TreeViewParams. This property is of type TGridTreeViewParamsEh and contains the
following sub-properties:
Subproperties of TDBGridEh.TreeViewParams:
Property
Type
Description
Name
GlyphStyle TTreeViewGlyphStyleEh View picture determines the state of the tree branches. Can
take the following values:
tvgsDefaultEh use a default picture
in
TDBGridEhStyle.GetActualGlyphStyle.

ShowTree
Lines

Boolean

tvgsClassicEh
tvgsThemedEh
tvgsExplorerThemedEh
Set this property to True to display the lines connecting the
elements of the tree.

Import/Export TDBGridEh data to/from various formats.


EhLib have a set of functions to export data from DBGridEh to Text, Csv, HTML, RTF, XLS and
internal formats. It can write data to stream (TStream object) or to file.
Example
Pascal:
SaveDBGridEhToExportFile(TDBGridEhExportAsText,DBGridEh1,'c:\temp\file1.txt',False);
C++:
SaveDBGridEhToExportFile(__classid(TDBGridEhExportAsText),DBGridEh1,"c:\\temp\\file1.t
xt",false);
EhLib have set of functions to import data from Text and internal formats to DBGridEh's
dataset. It can read data from stream (TStream object) or from file.
Procedures and classes to import and export data are in module DBGridEhImpExp.
Data Export:
To export the data, you can use the following classes:
TDBGridEhExportAsText to export data to a text file or stream.
TDBGridEhExportAsUnicodeText To export data to a text file or stream in Unicode format.
TDBGridEhExportAsCSV To export data to a delimited text file type ';'. You can change the
separator used globally permernnuyu DBGridEhImpExpCsvSeparator or property
TDBGridEhExportAsCSV.Separator.
TDBGridEhExportAsHTML To export in HTML.
TDBGridEhExportAsRTF To export in RTF format.
TDBGridEhExportAsXLS To export format VCLDBIF (This MS Excel format version 2). In this
format there is a limit on the length of text characters. The length can not exceed 255. We do
not recommend using this format since it is deprecated. To export to a format compatible with
MS Excel file and use the class TDBGridEhExportAsOLEXLS TDBGridEhExportAsXlsx or global
procedures and ExportDBGridEhToOleExcel ExportDBGridEhToXlsx.
TDBGridEhExportAsOLEXLS To export to a format compatible with MS Excel file and use the
class TDBGridEhExportAsOLEXLS TDBGridEhExportAsXlsx or global procedures and
ExportDBGridEhToOleExcel ExportDBGridEhToXlsx.
Also for export, you can use a global procedure
function ExportDBGridEhToOleExcel(DBGridEh: TCustomDBGridEh;
Options:
TDBGridEhExportAsOLEXLSOptions;
IsSaveAll:
Boolean
Variant;

True):

TDBGridEhExportAsXlsx To export data in the format Xlsx. The export is performed directly to
a file. The presence of additional libraries are not required.

Unloading Supported in Delphi XE2 and higher. For working of class unloading in earlier
versions of Delphi you must use the third-party tools to form the Zip file version 2. For more
information about unloading format Xlsx for Delphi XE2 version below read in the files section
<EhLib Archive>\ ZipProviders\
Also for export, you can use a global procedure
procedure ExportDBGridEhToXlsx(DBGridEh: TCustomDBGridEh;
const FileName: String; Options: TDBGridEhExportAsXlsxOptions; IsSaveAll:
Boolean = True);

TDBGridEhExportAsXMLSpreadsheet to export data in the format XML Spreadsheet. This


format is supported by Microsoft and can be used to transfer data to Microsoft Excel via the
clipboard. DBGridEh component is already using this format when writing data to the clipboard,
so that data can be transferred from DBGridEh in Microsoft Excel format with preservation of
the font, colors and types of data. The implementation of the class is the module DBGridEh
XMLSpreadsheetExp.
Data Import:
To import data, you can use the following classes:
TDBGridEhImportAsText to import a text file or stream in which the values of the fields are
separated by VK_TAB (#09).
TDBGridEhImportAsUnicodeText - to import a text file or stream in Unicode format.
TDBGridEhImportAsVCLDBIF This data format used for the data transfer of one grid to
another via the clipboard data.

Using the drop-down menu PopupMenu


At DBGridEh there is a PopupMenuParams property, which manages the construction
PopupMenu in the grid. By default, the grid uses the following properties to determine which
PopupMenu is displayed by pressing the right mouse button: TDBGridEh.PopupMenu,
TColumnEh.PopupMenu, TColumnEh.Title.PopupMenu. Using subproperties properties
TDBGridEh.PopupMenuParams can expand choice and formation of PopupMenu.
The PopupMenuParams property includes the following subproperties:
BuildMenuOnPopup: Boolean Defines if it is necessary to build a new
PopupMenu or use ready-made. If BuildMenuOnPopup = True, the grid will form a new
PopupMenu before being displayed. This allows you to create new elements
PopupMenu or change / delete existing PopupMenu before displaying on the screen.
Thus, the elements PopupMenu can be formed dynamically depending on the location
display, and other conditions affecting the list.
UseGlobalMenu: Boolean Specifies whether you want to add items to the
menu in the global PopupMenu grid. The elements are formed in a global menu
procedure TDBGridEhCenter.BuildCellPopupMenu. By default BuildCellPopupMenu adds
nothing. You can write your version of TDBGridEhCenter class and override the method
BuildCellPopupMenu to add new elements to the PopupMenu all Grid project. See more
info in the section Using global properties for TDBGridEh.

Using properties of TDBGridEh.IndicatorTitle.


Using properties of the TDBGridEh.IndicatorTitle object you can control the behavior of the grid
when the left-top cell is clicked.

Set TitleButton property to True value to make top-left cell working as button. When
TitleButton is True the properties DropdownMenu and UseGlobalMenu are also taken into
consideration. If UseGlobalMenu is True then grid will form the dropped down menu using
global property DBGridEhCenter.IndicatorTitleMenus.IndicatorTitleMenus. If DropdownMenu is
also assigned then all elements of this menu will be added to the dropped down menu after
elements of global menu.
Subproperies of IndicatorTitle property:
property DropdownMenu: TPopupMenu;
Identifies the pop-up menu, which elements will be displayed when IndicatorTitle cell is
clicked.
property ShowDropDownSign: Boolean default False;
Determines whether to display the black triangle in upper left when cell of the grid.
property TitleButton: Boolean;
Determines whether the upper left cell works as button.
property UseGlobalMenu: Boolean default True;
Determines whether grid will take into account the
DBGridEhCenter.IndicatorTitleMenus property to form drop down menu.
TDBGridEh.IndicatorTitle property have the following sub-properties:
Property Name

Property Type

Description

DropdownMenu

TPopupMenu

Define a drop-down menu whose items will be


displayed when you click on the cell IndicatorTitle

ShowDropDownSign Boolean

Specifies whether to display a black triangle pointing


down in the top left cell

TitleButton

TitleButton

Specifies that the upper-left cell works as a button

UseGlobalMenu

Boolean

In forming the pull-down menu to use the properties


of the global object DBGridEhCenter.IndicatorTitleMenus.

Using global properties for TDBGridEh.


The Library has a set of global properties and event, which influence all grids that are created in
the project. You can adjust this properties or event, for instance, in the main Form of your
project, and all grids of the project will change its behaviors according to these properties. To
control the global behavior of grids there are global objects such as the TDBGridEhCenter and
TDBGridEhStyle type. The First one is used to control the behavior of the grids, the second one
is to control the style of grids showing.
General information about TDBGridEhCenter class:
Use global function DBGridEhCenter to access the elements of the TDBGridEhCenter object:
function DBGridEhCenter: TDBGridEhCenter;
It returns the global object of the type TDBGridEhCenter, which controls the behavior of all
grids. You may inherit TDBGridEhCenter class, rewrite virtual methods and register your object
of managing using SetDBGridEhCenter function:
function SetDBGridEhCenter(NewGridCenter: TDBGridEhCenter): TDBGridEhCenter;
It set new object of management and returns the old object. The Old object, in most cases, is
required to destroy.
Properties and events of the TDBGridEhCenter class:
Properties:
property FilterEditCloseUpApplyFilter: Boolean;

Determines whether the SubTitleFilter will be applied right after choosing value from
dropped down list or always need to press Enter key to apply filter.
property IndicatorTitleMenus: TDBGridEhStyleIndicatorTitleMenusEh;

Specifies the list of elements, which will be visible in IndicatorTitle of dropped down
menu when TDBGridEh.IndicatorTitle.UseGlobalMenu = True and
TDBGridEh.IndicatorTitle.TitleButton = True.
TDBGridEhStyleIndicatorTitleMenusEh is a set which consists of following values
itmVisibleColumnsEh - Display the menu item with list of columns, cliquing on
which possible to show or hide column.
itmCut
- Display Cut menu item
itmCopy
- Display Copy menu item
itmPaste
- Display Paste menu item
itmDelete
- Display Delete menu item
itmSelectAll
- Display SelectAll menu item
Events:
OnApplyFilter: TNotifyEvent;
This event is called when grid apply SubTitleFilter. Sender parameter is a grid that
applies filter. In the handler of event you can call default handler DBGridEhCenter.DefaultApplyFilter.
OnApplySorting: TNotifyEvent;

This event is called when grid apply sorting. Sender parameter is a grid that applies
sorting. In the event handler you can call default handler DBGridEhCenter.DefaultApplySorting.
OnBuildIndicatorTitleMenu: TDBGridEhBuildIndicatorTitleMenu;
This event occurs when grid forms the dropped down menu that appears when mouse is
clicked on the upper left cell of grid. Event occurs if TDBGridEh.IndicatorTitle.TitleButton =
True. Sender parameter is a grid in which IndicatorTitle button was pressed. PopupMenu
parameter is a menu that will is displayed under cell. You can call default handler that build
menu items by default:
DBGridEhCenter.DefaultBuildIndicatorTitleMenu(Grid, PopupMenu);
and then perform additional code, for instance, to add one more menu elements.
// Below is an example that demonstrate how to add new menu item in list of
IndicatorTitle menus.
// Declare global menu item for printing the grid.
var DBGridEhPreviewIndicatorMenuItem: TDBGridEhMenuItem;
// In public section of main Form declare methods for OnBuildIndicatorTitleMenu
event.
procedure BuildIndicatorTitleMenu(Grid: TCustomDBGridEh; var PopupMenu:
TPopupMenu);
// Event procedure that will be call when menu item is selected.
procedure MenuEditClick(Sender: TObject);
// In TMainForm.OnCreate event of the program, assign the event on that will be form
IndicatorTitle menu items.
procedure TForm1.FormCreate(Sender: TObject);
begin
DBGridEhCenter.OnBuildIndicatorTitleMenu := BuildIndicatorTitleMenu;
end;
// Method Itself.
procedure TForm1.BuildIndicatorTitleMenu(Grid: TCustomDBGridEh; var PopupMenu:
TPopupMenu);
begin
// At first it calls the default method of menu building.
DBGridEhCenter.DefaultBuildIndicatorTitleMenu(Grid, PopupMenu);
// Then create new item.
if DBGridEhPreviewIndicatorMenuItem = nil then
DBGridEhPreviewIndicatorMenuItem := TDBGridEhMenuItem.Create(Screen);
DBGridEhPreviewIndicatorMenuItem.Caption := 'Preview';
DBGridEhPreviewIndicatorMenuItem.OnClick := MenuEditClick;
DBGridEhPreviewIndicatorMenuItem.Enabled := True;
DBGridEhPreviewIndicatorMenuItem.Grid := Grid;
// And add it at the end of the menu list.
PopupMenu.Items.Insert(PopupMenu.Items.IndexOf(DBGridEhSelectAllIndicatorMenuItem)+1,
DBGridEhPreviewIndicatorMenuItem);
end;
// The Handler of new menu item.
procedure TForm1.MenuEditClick(Sender: TObject);
begin
PrintDBGridEh1.DBGridEh := TDBGridEh(TDBGridEhMenuItem(Sender).Grid);
PrintDBGridEh1.SetSubstitutes(['%[Today]',DateToStr(Now)]);

PrintDBGridEh1.Preview;
end;
OnCellMouseClick: TGridEhCellMouseEvent;
type TGridEhCellMouseEvent = procedure (Grid: TCustomGridEh; Cell:
TGridCoord;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer) of object;

This event occurs on mouse clicking in any cell of the grid. Event has such parameters:
Grid; coordinates of the cell (Cell); Button, which was pressed on mouse (Button); Shift
state of keyboard (Shift) and coordinates of the clicked point inside cell (X, Y). In the
handler of event you can call the default handler DBGridEhCenter.DefaultCellMouseClick.
OnIndicatorTitleMouseDown: TGridEhCellMouseEvent;
type TGridEhCellMouseEvent = procedure (Grid: TCustomGridEh; Cell:
TGridCoord;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer) of object;

This event occurs when the mouse click on upper left cell of the grid occurs. In the
handler of event you can call default handler DBGridEhCenter.DefaultIndicatorTitleMouseDown.
OnLocateText: TLocateTextEventEh;
type TLocateTextEventEh = function (Sender: TObject;
const FieldName: string; const Text: String; Options:
TLocateTextOptionsEh; Direction: TLocateTextDirectionEh; Matching:
TLocateTextMatchingEh; TreeFindRange: TLocateTextTreeFindRangeEh):
Boolean of object;
This event occurs during increment or dialogue searching in the grid.

The General information about TDBGridEhStyle class:


To access elements the global DBGridEhStyle object use function:
function DBGridEhStyle: TDBGridEhStyle;
It returns the current object of the type TDBGridEhStyle, which controls imaging of all grids. You
can inherit TDBGridEhStyle, overwrite virtual methods controlling image of the grid, and
register new object to manage, using next function:
function SetDBGridEhStyle(NewGridStyle: TDBGridEhStyle): TDBGridEhStyle;
Call this function to set new object of image controlling. It returns old object. In most cases it is
necessary to delete old object.
Properties of the TDBGridEhStyle class:
property LuminateSelection: Boolean default True;
This property determines whether need to illuminate the selected area in grid. If
LuminateSelection = False then the selected area will be painted by clHighlight color. If
LuminateSelection = True then selected area will be painted by method as if you see on the
area through the transparent glass of the clHighlight color.

property IsDrawFocusRect: Boolean default True;


This property determines whether to draw pointed square around the current cell or
row in the grid.

Other features.
Frozen zone.

Frozen zone is columns the left part of the grid that remains unchanged when the grid is
scrolled to the left or right direction. Unlike the fixed columns the frozen columns can receive
the edit focus. To specify the count of the un-scrolling columns you need to set FrozenCols
property.
Multiselect

TDBGridEh allows to select records, columns and rectangle areas for following operations
above the selected area.
To customize multiselecting you can use next properties:
dgMultiSelect in Options property - Specifies whether the multiselect is allowed.
dghClearSelection in OptionsEh property - Specifies whether the selection will be cleared
after user move to the next cell.
EditActions property - Specifies actions which user can execute above the selection
(Copy,Cut,Delete,Paste,SelectAll).
AllowedSelections - Specifies the types of selections that is allowed to do (Rows, Columns,
Rectangle area, All).
Selection property specifies a current multiselection state, selected records, columns or
rectangle area and it has properties and functions to access them.
TDBGridEh allows you to select records, columns and rectangle areas for further operations on
the selected area (for example, for copying to the clipboard). To enable multiple selection, set
the following properties:
dgMultiSelect in Options property - determines the possibility of multiple selection.
dghClearSelection in OptionsEh property - determines whether or not to clear deselecting
after the user has moved to another cell.
EditActions - defines the actions a user can perform with a selected area (Copy, Cut, Delete,
Paste, SelectAll).
AllowedSelections - determines the types of permitted areas that user can select (Rows,
Columns, Rectangle area, All).
Selection - defines the current status of multiple selection: the selected records, columns or a
rectangular area and includes features and functions to access them.
If user change the selected area, the OnSelectionChange event occurs.
To access the selected area, use the following properties of the grid:
SelectedRows: TBookmarkListEh It contains a list of selected records.
Selection: TDBGridEhSelection It contains information on the selected area and the list of
selected items.
Selection.SelectionType

Use Selection.SelectionType property to determine the type of the selected area. SelectionType
property is of enumeration type, and can contain one of the following
gstRecordBookmarks Records are Selected. Use the property SelectedRows or
Selection.Rows access to selected records.
gstRectangle Rectangular area is selected. Use Selection.Rect property to get the
border of the selected area.
gstColumns Columns are selected. Use Selection.Columns property to access the list
of selected columns
gstAll all grid is selected.
gstNon the grid has no multiple selection.
Selection.Rows
Property Selection.Rows (as did SelectedRows) has type TBookmarkListEh. Pointers to entries in
the list are stored as bookmarks DataSet (type TBookmark) and has the following properties
and methods:
Property Name

Property Type

Description

Count

Integer

The number of entries in the list of bookmarks

Items[Index: Integer]

TUniBookmarkEh

The property to access elements of an array of


selected bookmarks.

CurrentRowSelected

Boolean

The property returns and sets, if the current selected


entry in the list of selected records.

Selection.Rect
The Selection.Rect property is of TDBGridEhSelectionRect type. The property contains the
coordinates rectangel selected area. TDBGridEhSelectionRect Type gase the following
properties and methods:
Property Name

Property Type

Description

BottomRow

TUniBookmarkEh

Pointer to the lower border area. Index specifies the


location as a bookmark for a record in DataSet.

LeftCol

Longint

The column number of the left border of the selected


area.

TopRow

TUniBookmarkEh

A pointer to the upper boundary of the field.

RightCol

Longint

Column number right border of the selected area.

method
function DataCellSelected(DataCol: Longint; DataRow: TUniBookmarkEh): Boolean;
Returns information whether said cell within the selected area.

Selection. Columns
The Selection.Columns property is of TDBGridEhSelectionCols type. The property contains a list
of selected columns. TDBGridEhSelectionCols type have the following properties and methods:
Property Name

Property Type

Description

Count

Integer

The number of selected columns.

Items[Index: Integer]

TColumnEh

The property sets the access to the elements of the


selected columns.

Save and restore grid and columns layout to/from registry or ini file.

TDBGridEh have set of routines to save and restore grid and columns layout to/from registry or
Ini file:
RestoreColumnsLayout
Restore Columns Order , Width , SortMarker from registry.
RestoreColumnsLayoutIni
Restore Columns Order , Width , SortMarker from the ini file.
RestoreGridLayout
Restore Columns Order, Width, Visibility, SortMarker, Sortmarked index and/or row
height from registry.
RestoreGridLayoutIni
Restore Columns Order, Width, Visibility, SortMarker, Sortmarked index and/or row
height from the Ini file.
SaveColumnsLayout
Save Columns Order, Width, SortMarker in registry.
SaveColumnsLayoutIni
Save Columns Order, Width, SortMarker in the ini file.
SaveGridLayout
Save Columns Order, Width, Visibility, SortMarker, Sortmarked index and row height in
registry.
SaveGridLayoutIni
Save Columns Order, Width, Visibility, SortMarker, Sortmarked index and row height in
the Ini file.

"Blackout" of the grid while loading a data.

TDBGridEh allows you to "black out" grid while loading data. This allows you to show the user
that a melon time DataSet loads data from the server. Grid
in the dark makes a smooth transition from the standard
picture to a darkened and back. Use StartLoadingStatus
FinishLoadingStatus methods to display the status of
downloading and reset it back respectively.You can call
methods that reload the data in DataSet between calls to these methods.
StartLoadingStatus and FinishLoadingStatus procedures have the following parameters:

procedure StartLoadingStatus(
const LoadingCaption : String = ''; // Text for Downloading staus
RenderDuration: Integer = -1 // Duration of the transition state
);
procedure FinishLoadingStatus(
RenderDuration: Integer = -1 // Duration of the transition state
);

Highlighting fields require input values

The DataSet fields that require that data entry, property Field.Required is set to True. If you try
to move to a new record in DataSete (grid) did not complete one of the fields requires a value,
DataSet throw an exception, and will not leave the post until the field will not be filled or
recording all changes will be canceled.
The grid has the ability to highlight a cell in
which there are fields with mandatory values.
Set
TDBGridEh.ColumnDefValues.HighlightRequired
or TColumnEh.HighlightRequired to highlight
such cells. Grid will emphasize the red line pnuktirnoy required input values.
You can also write to the event TColumnEh.OnCheckDrawRequiredState to manage when you
have to draw a line indicator of mandatory data entry. In the event handler will set DrawState
parameter to True to display a line-indicator for the relevant records and fields.
Saving \ Restore position of the current row in the grid after the mass data changes in DataSet

When data changes in the DataSet using the methods DataSet.DisableControls DataSet.EnableControls current position in the grid may shift, causing discomfort to the user.
To avoid shifting position use methods
procedure TCustomDBGridEh.SaveVertPos(KeyFieldNames: String);
procedure TCustomDBGridEh.RestoreVertPos(KeyFieldNames: String);

to save the position of the grid before updating and restoring the position of the grid after the
update. The KeyFieldNames parameter must contain key field name (or a list of fields separated
by semicolons). The value of key fields will be used to restore the position when the DataSet
DataSet reopen during processing.

Other features and events of the component


TDBGridEh.Options
property Options: TDBGridOption
The property has a set of type and can contain the following values.
dgEditing
The grid is allowed to open the text editor by Enter or F2 key.

dgAlwaysShowEditor
Always display the text editor of the cell during the moving from cell to
line.
dgTitles
Show title row.
dgIndicator
Show Indicator column.
dgColumnResize
Allow resize and move columns.
dgColLines
Draw vertical dividing lines.
dgRowLines
Draw horizontal dividing lines.
dgRowSelect
Select the entire row of the grid instead of a single cell.
dgAlwaysShowSelection
Always draw a selection on the grid. When the grid does not have the
input focus, the area will be displayed in gray color.
dgConfirmDelete
Show confirmation window before removing the record on Ctrl + Delete.
dgCancelOnExit
Cancel Edit Mode using DataSet.Cancel if DataSet was set in append
mode, but user did not do any changes to the row.
dgMultiSelect
Allow select areas in the grid. For more information, see. In the
"Multiselect and working with the clipboard".
TDBGridEh.OptionsEh
property OptionsEh: TDBGridEhOption
The property has a set of type and can contain the following values.
dghFixed3D
Draw a border around the 3D cells fixed grid area.
dghFrozen3D
Draw a border around the 3D cells frozen area.
dghFooter3D
Draw a border around the 3D cells footer.

dghData3D
Draw 3D border around the cells containing the data records DataSet.
dghResizeWholeRightPart
In the AutoFitColWidths.
dghHighlightFocus
Highlight the current cell by color or thems style.
dghClearSelection
Clear selection mode MultiSelect when the Grid moves from cell to cell
using the keyboard.
dghFitRowHeightToText
When RowSizingAllowed = True, determines a change row heights to
customize the height of the mouse so that they always get the exact
number of lines of text without clipping.
dghAutoSortMarking
Change markers of sorting by clicking on the title which TitleButton =
True.
dghMultiSortMarking
Allows set markers sorting multiple columns at once, to set markers
sorting Run-Time, the user must press and hold down the Ctrl key.
dghEnterAsTab
Enter key behaves key Tab, that is, calls go to the next cell.
dghTraceColSizing
When dghColumnResize value is set then this value determines that it is
necessary to change the size of the column with the mouse while moving
the mouse. If the data value is not set, the size of the column will change
after you release the mouse button.
dghIncSearch
Allowed transition incremental search mode by Ctrl + F button
dghPreferIncSearch
If set dghIncSearch, the installation of this value determines the need
vlyuchaet incremental search mode immediately by pressing any letter
key numeric keypad. If this value is not set, the switch-over to
incremental search only after pressing a combination of Ctrl + F.
dghRowHighlight
Highlight the entire row of the grid. Unlike RowSelect, mode RowHighlight
notion of the current cell remains.
dghDblClickOptimizeColWidth

Optimize column width so that the column until all text cell by doubleclicking on the vertical dividing line header.
dghDialogFind
Allow search in the search grid through dialogue. Search dialog is opened
by pressing the Ctrl + F.
dghRecordMoving
Allow moving records by mouse.
dghShowRecNo
Show record number in the column indicator.
dghColumnResize
Allow the mouse to resize the column.
dghColumnMove
Allow the mouse to move the columns.
dghAutoFitRowHeight
Adjust the height of the row so that each cell until all text.
dghHotTrack
Highlight the cell on which the mouse cursor.
dghExtendVertLines
Is extended until the end of the vertical lines of the grid down.

TDBGridEh.DataRowCount
function TDBGridEh.DataRowCount: Integer;
Returns the number of rows of data excluding the header lines and footers.

Access to protected class methods


In complex programs and algorithms the use the Grid, you may need to access the protected
fields, methods, or properties of a class.
The Object Pascal language has the opportunity to access protected data.
For this purpose, the module to which you plan to use access, declare a class that derives from
TDBGridEh while changing nothing in the class. In the requaried place of code, perform the
conversion to this. Object Pascal allows to access to all methods of the class if it is declared in
the same module.
Below is an example code:
unit Unit1;
type
TfrVertGrid = class(TFrame)


Grid1: TDBGridEh;
end;
implementation
type
TDBGridEhCrack = class(TDBGridEh);
procedure TfrVertGrid.ToolButton1Click(Sender: TObject);
begin
TDBGridEhCrack(Grid1).ProptectedMethod;
end;

Converting existing TDBGrid component to TDBGridEh.


Although TDBGridEh is not inherited from TCustomDBGrid component, there are many alike
properties in TDBGridEh and in TDBGrid.
It allows us to convert existing TDBGrid component to TDBGridEh with minimum losses.
To convert existing TDBGrid component to TDBGridEh follow next instructions:
Open Form with TDBGrid component in Delphi IDE.
Open Form as Text (Alt-F12)
Rename all TDBGrid objects to TDBGridEh ('object DBGrid1: TDBGrid' -> 'object DBGrid1:
TDBGridEh')
Switch to view Form back as a Form (Alt-F12)
Rename all TDBGrid objects in Form declaration to TDBGridEh ('DBGrid1: TDBGrid;' -> 'DBGrid1:
TDBGridEh;' )
Try to recompile project.

Using TPrintDBGridEh component


TPrintDBGridEh allows printing DBGridEh components on the printer.
Select TPrintDBGridEh in Delphi IDE component palette and drop it on a form. Select TDBGridEh
component in DBGridEh property. Use Print and Preview procedure to print grid on a printer or
to preview grid in a preview Form.
TPrintDBGridEh component is for previewing and printing component DBGridEh.
To set TPrintDBGridEh in Design-Time, place components on the Form and assign
TPrintDBGridEh.DBGridEh a property of one of the instances TDBGridEh.
Ti Print Grid at Run-Time call the TPrintDBGridEh.Print method.
Use the TPrintDBGridEh.Preview to open the preview window before before printing

Rich text before and after grid


TPrintDBGridEh allows to print/preview rich text before and after grid. Use AfterGridText and
BeforeGridText to specify text. Using SetSubstitutes method you can substitute text in
BeforeGridText and AfterGridText properties upon print/preview process.
TPrintDBGridEh allows to print Rich text before and after grid. To do this, use AfterGridText and
BeforeGridText properties. Also, using the method SetSubstitutes, you can specify the
substitution text in the BeforeGridText and AfterGridText properties in print / preview. A
property of AfterGridText and BeforeGridText have type TStrings, although store a data type
TRichEditStrings.
Below is an example code for printing Rich text with the possibility of substitution:

PrintDBGridEh1.SetSubstitutes(['%[Today]',DateToStr(Now)]);
PrintDBGridEh1.Preview;

Padding margins
Use TPrintDBGridEh.Page property to set the borders of the page margins. The
TPrintDBGridEh.Page property is of TPageParams type and has the following subproperties:
property
property
property
property

BottomMargin: Currency
LeftMargin: Currency
RightMargin: Currency
TopMargin: Currency

Low Indent.
Left Indent.
Right indent.
Top indent.

Units are defined by TPrintDBGridEh.Units property and may be set to MM or Inches.

Page header and footer.


Use the PageFooter and PageHeader properties to set the text in the bottom or the page
header.
The headers and footers, you can use the following macros:
'&[Page]'
current page
'&[Pages]'
total pages in the document
'&[ShortDate]'
Date in short format
'&[Date]'
Date
'&[LongDate]'
Date format LongDateFormat
'&[Time]'
The time

Selecting print page orientation


TPrintDBGridEh doesnt have special properties to set page orientation. To do it, you need to
set orientation of virtual printer before calling Print or Preview procedure. Like this code:
uses ......, PrViewEh, Printers.
..............
procedure TForm1.bPreviewClick(Sender: TObject);
begin
PrinterPreview.Orientation := poLandscape;
PrintDBGridEh1.Preview;
end;

Other events and a property of TPrintDBGridEh


TPrintDBGridEh.Options
The property is of type TPrintDBGridEhOptions and can contain the following values:
pghFitGridToPageWidth
Reduce the print scale so that the width of the grid was reduced in width
of the page.

pghColored
Keep color printing. If the value is not contained in the property, the grid
will be printed in black and white.
pghRowAutoStretch
Stretch row height to accommodate all the text in the cell text wraps to a
new line.
pghFitingByColWidths
If the property is set pghFitGridToPageWidth, instead of the total scaling
when printing decreases the width of columns.
pghOptimalColWidths
Fit the column width to fit the contents of each cell within the same line
of text.

TPrintDBGridEh.PrintFontName
If you set this property, it will be used for printing the specified font property, instead of
the font specified in DBGridEh.
TPrintDBGridEh.Title
Title Grid. Title is printed on each page of the total cap for all the columns of the grid.
TPrintDBGridEh.OnBeforePrint
Event is called after printing a grid. In the event you can set a property of certain grid to
print it more "correct".
TPrintDBGridEh.OnAfterPrint
Event is called after printing a grid. In the event you can return a property of the grid
established in the event OnBeforePrint.
TPrintDBGridEh.OnPrinterSetupDialog
The event is called when the request for the opening of the press DIAL. If the event is
not set, it uses the method TPrintDBGridEh.PrinterSetupDialogPreview.

Features that current version of TPrintDBGridEh is not supported.


This version of TPrintDBGridEh does not support next features:
TPrintDBGridEh can not print/preview several grids on the single page.

Using TDBVertGridEh component


General concepts of TDBVertGridEh component.

Component TDBVertGridEh is a visual component such like a vertical grid. The component is
used to display and edit a single DataSet record in a vertical orientation. The data is displayed in
two columns. The first column displays the names of
the fields and the second column show values of the
current record.
In the general case, the each row in the component
corresponds to a one field in the DataSet.
TDBVertGridEh and TDBGridEh components have a
common ancestor - TCustomDBAxisGridEh and have
similar functionality. TDBGridEh component can be
regarded as a table with a horizontal display of records
and TDBVertGridEh as vertical. In the current version
of EhLib TDBVertGridEh can display only one record on
the screen.
If you've worked with TDBGridEh component, then for understanding the properties of the
components TDBVertGridEh their properties can be compared as follows:

Properties of
TDBGridEh

Description

Properties of
TDBVertGridEh

Description

Columns

Columns of the grid, that


corresponds to fields of the
dataset.

Rows

Rows of the grid, that


corresponds to fields of the
dataset.

Options

Setting up the basic


properties DBGirdEh.

Options

Setting up the basic


properties DBVertGridEh.

ColumnDefValues The default values for


columns TColumnEh.

RowsDefValues

The default values for rows


TFieldRowEh.

GridLineParams

GridLineParams

Property works similarly.

DataColParams

Configuring column display


data.
Configuring the column
headers display rows of data.

Color settings of dividing lines


in the grid.

<There is no
analog>
TitleParams

Configuring the column


headings of a column.

LabelColParams

IndicatorParams

Configuring the indicator


column.

<There is no
analog>

Flat

Paint 3D grid cell in a slightly


raized state.

Flat

DrawGraphicData Display graphical data from

Property works similarly.

DrawGraphicData Property works similarly.

fields like TGraphicField


DrawMemoText

Display text data from Memo


fields.

DrawMemoText

Property works similarly.

Column header fields


Use properties TDBVertGridEh.LabelColParams or TDBVertGridEh.LabelColParams to adjust the
display format of header fields.
Use subproperties of Rows[i].RowLabel properties to adjust the format of a specific line.
Use a TDBVertGridEh.LabelColWidth property to specify the width of the column header fields.

String types and data types in the data lines


Collection DBVertGridEh.Rows column consists of elements of the collection TFieldRowEh. All
lines have the same type - TFieldRowEh, but the kind of data displayed in each column is
different, and depending on the type of field assignments through property
TFieldRowEh.FieldName, as well as the combination of the properties assigned Row. For
example, if the DataSet field is of TBooleanField type, in line instead of the text will display
Checkbox. You can customize the properties of Row to display checkboxes for any other type of
field, if you set the property to True TFieldRowEh.Checkboxes and fill in additional properties.
The following instructions describe how to configure the properties of the string to achieve the
desired display, behavior and form cell editor.

Access to the grid rows

You can use these methods to a property of, and access to the columns of the grid:
property DBGridEh.Rows: TDBVertGridRowsEh This is the main collection
lines
property DBGridEh.FieldRows[const FieldName: String]: TFieldRowEh Search row by a
field name. If the string, which TFieldRowEh.FieldName = FieldName not found, an
exception is thrown.
function FindFieldRow(const FieldName: String): TFieldRowEh; Search row by a field name. If the row, which TFieldRowEh.FieldName = FieldName not
found it returns Nil.

Columns of data type Combobox editors and other features rows.

Other features of grid lines operate similar to how the columns operates in DBGridEh. They are
described in detail in the section "Types of columns and data types in DBGridEh.

Grouping rows by Category


TDBVertGridEh component allows you to group rows into categories. Use sub-properties of
TDBVertGridEh.RowCategories property to manage a categories.
Grid lines can be grouped into categories based on:
- ategory name
- Field type
- Presence / absence of values in the current record.
To activate the grouping by category, set
TDBVertGridEh.RowCategories.Active property to True.
Type used to group categories defined by the property
CategoryGroupingType. CategoryGroupingType has
TCategoryGroupingTypeEh type and can contain the
following values:
cgtFieldRowCategoryNameEh Form category
basing on TFieldRowEh.CategoryName
property value. The number of categories determined by the number of unique
values in the list of TDBVertGridEh.Rows[i].CategoryName values. Additional
properties of the categories can be set using the properties of the
TDBVertGridEh.RowCategories.CategoryProps collection.
cgtEmptyNotEmptyValueEh - To form category based on the presence of values in fields
in DataSet. The grid line will fall into one of two categories. Category 1 - a field in
which the values of the current record is not Null. Category 1 - a field in which
the values of the current record = Null.
cgtFieldDataTypeEh - To form category based on the type of fields. Fields will fall into
one of the following categories: Text fields, numeric fields, Logical fields, field
type DateTime fields such as BLOB, another type of field.
With the TDBVertGridEh.RowCategories.CategoryProps property you can specify additional
parameters such as:
DisplayText The text that will be displayed in the grid
DefaultExpanded Status Expanded / Collapsed category as the branches of a tree on
the first grid displayed on the screen.
Simply create a collection element listed as the Name property in the name of the category and
is additionally specify a property.
Use sub-properties of a TDBVertGridEh.RowCategories property to set Color Font ParentFont to
adjust the font and color of the grouping string category.
Using the TDBVertGridEh.RowCategories.RowMoveOptions property you can allow Categories
to move by mouse at the Run-Time, and move the items from category to category.
Use OnRowCategoriesNodeExpanded and OnRowCategoriesNodeCollapsed events to perform
certain actions when a user opens and closes certain category.

Sort by column header row.


The component allows TDBVertGridEh sortirovavt line on the column headers fields. To specify
the type of the sort use TDBVertGridEh.RowsSortOrder property. The RowsSortOrder property
is of TDBVertGridRowsSortOrderEh enumeration type and can contain the following values:
vgsoByFieldRowIndexEh

Sort by order of the fields in the collection


TDBVertGridEh.Rows (Sort by default).

vgsoByFieldRowCaptionAscEh

Sort by Title fields Row[i].RowLabel.Caption ascending.

vgsoByFieldRowCaptionDescEh

Sort by FIeldRow
descending.

Title

Row[i].RowLabel.Caption

Multiple choice and work with the clipboard.


TVertDBGridEh allows you to select the line and rectangular areas for further operations on the
selected area (for example, for copying to the clipboard). To enable multiple selection, set the
following properties:
EditActions - defines the actions a user can perform with a selected area (Copy, Cut,
Delete, Paste, SelectAll).
AllowedSelections - determines the types of permitted allocation that can be performed
in a grid user (vgstRowsEh, vgstRectangleEh, vgstAllEh).
Selection It contains properties containing information about the selected area.
The property is of type TVertDBGridEh.Selection TDBVertGridSelectionEh and contains the
following properties and methods.
property AnchorRowIndex: Integer
Fixed line number in the allocation data of the rectangular area.
property Rows: TFieldRowSelectionListEh
List of lines in the allocation of full rows records.
property SelectionType: TDBVertGridSelectionTypeEh
Type selection
property ShipRowIndex: Integer
Number "floating" line in the allocation of the rectangular area data.
function IsCellSelected(ACol, ARow: Integer): Boolean;
Returns True if the cell gets in the selected area.
procedure Clear;
Clear selection. SelectionType = vgstNonEh.
procedure SelectAll;
Select the entire grid. SelectionType = vgstAllEh.

procedure SelectAllDataCells;
Select a rectangular area, so that it will get all the data cells.
Use TVertDBGridEh.Selection.SelectionType property to determine the current view selection.
Selection.SelectionType has TDBVertGridSelectionTypeEh type and can contain the following
values
vgstRowsEh
Allocate a full-line recording. To access the recording, use a
dedicated property Selection.Rows.
vgstRectangleEh Select a square region of the data. For access to the borders of the
area and use the properties of Selection.AnchorRowIndex
Selection.ShipRowIndex.
vgstAllEh
Select the entire grid.
vgstNonEh
Multiple selection is absent.
The property is of type TVertDBGridEh.Selection.Rows TFieldRowSelectionListEh and contains
the following properties and methods:
property Count: Integer
It contains the number of selected lines.
property Items[Index: Integer]: TFieldRowEh
Pointers on selected lines
procedure AddSelectedRow(ARow: TFieldRowEh);
Adds a new line type TFieldRowEh the list of selected lines.
procedure Clear;
Clears the list of selected lines
procedure RemoveSelectedRow(ARow: TFieldRowEh);
Deletes the line type from the list TFieldRowEh selected lines.
procedure SelectAll;
Selects all lines in the TVertDBGridEh.
When the user selects a rectangular area of data in the data grid on the allocation are stored in
the properties and Selection.AnchorRowIndex Selection.ShipRowIndex. When a rectangular
selection one cell always remains fixed and specifies anchor selection AnchorRowIndex. The
second cell specifies ShipRowIndex second selection border. If the user presses and drags the
mouse up or down, the value changes in ShipRowIndex property.

Set fonts and coloring grid cells using events


To control the rendering content of cells in the grid data partition, there are two types of
events.
Type 1
event to replace the rendering parameters. It's events like
TDBVertGridEh.OnGetCellParams and TFieldRowEh.OnGetCellParams. In these events, it is

necessary to replace the parameters such as font, font, text alignment, the number of pictures
ImageList, etc., but drawing itself carries the internal code of the grid.
Type 2

events in which event handler executes rendering the cell contents.

Here is a list of events that you can use to customize the font attributes and color of the cell
before the data is printed. At the time of calling all of the following events DataSet will already
be on the record, the contents of which it is necessary to render, so you can access the field
values using the methods like TDataSet.FieldByName(..).Value. Do not change the properties of
the grid or columns inside those events. This may cause a program loops.
TDBVertGridEh.OnGetCellParams
Use this event to replace the font settings and the background color of the cell before
rendering. Event parameters are similar to the events for TDBGridEh.OnGetCellParams.
TFieldRowEh.OnGetCellParams
Use this event to replace the cell parameters a particular column before rendering. Parameters
are similar to the events soybtiya TColumnEh.OnGetCellParams.
TDBVertGridEh.OnAdvDrawDataCell TFieldRowEh.OnAdvDrawDataCell
Use this event to draw the data in the data cells of the grid. The event code set Processed
argument to True to specify that you have handled the process of drawing. If Processed leave
False, the grid method will render the contents of a cell using default method. You can, if
necessary, change the ARect and Params and cause Grid.DefaultDrawRowDataCell or leave
Processed able to False and do not induce Grid.DefaultDrawRowDataCell. To change the data
output to the screen, use the event parameters Params and Grid.Canvas if you draw a cell data
function on their own using GDI.

Unload the contents of the components in TDBVertGridEh Xlsx file


The library contains a set of classes and methods for "direct" export data TBVertGridEh the file
or stream in Xlsx format and XMLSpreadsheet.
To unload Xlsx format, use TDBVertGridExportToXlsxEh class or global procedure.
TDBVertGridExportToXlsxEh = class;
The class implements VertGridEh upload data to a file in Xlsx format (MS Excel file format).
Unloading is carried out directly into a file without using additional libraries and OLE objects.
Full unloading works in versions of Delphi since Delphi XE2. To operate in earlier versions of
Delphi you must use the third-party to form the Zip file version 2.
To upload data, use procedure:
procedure ExportDBVertGridEhToXlsx(DBVertGridEh:
TCustomDBVertGridEh; const FileName: String);
To upload data in a format XMLSpreadsheet use global routine:

procedure DBVertGridEh_ExportToStreamAsXMLSpreadsheet(DBVertGridEh:
TCustomDBVertGridEh; Stream: TStream; Options: TExportAsXMLSpShOptionsEh;
ForWholeGrid: Boolean);
DBVertGridEh already uses this procedure to upload the data to the clipboard for pasting data
to MS Excel. When transferring data in this format, MS Excel receives information not only
about the content of the data but also about font, color, lines and the type of data.
Other features and events of the component
property Options: TDBVHGridOptions
Property type set. It may contain the following values.
dgvhEditing
The grid is allowed to open the text editor by clicking on the Enter or F2
Key.
dgvhAlwaysShowEditor
Always display the text editor of the cell during the transition from line to
line.
dgvhLabelCol
Display column with header fields.
dgvhRowResize
Permission is granted to change the row height using the mouse.
dgvhRowMove
Permission is granted to move the line with the mouse.
dgvhColLines
Draw a vertical dividing lines
dgvhRowLines
Draw a horizontal dividing line
dgvhTabs
Edit the Tab key in the grid. By Tab to move the cursor to the next line.
dgvhAlwaysShowSelection
Always draw a selection on the grid. When the grid does not have the
input focus area will be displayed gray color.
dgvhConfirmDelete
Show confirmation dialog before removing the recording Ctrl + Delete
dgvhCancelOnExit
Exit Edit Mode dataset methods DataSet.Cancel if grid included in append
mode recording, but did not do any changes to the rows.

property OptionsEh: TDBVHGridOptionsEh


Property type set. It may contain the following values.
dgvhHighlightFocusEh
Highlight the current cell color or style.
dgvhClearSelectionEh
Clear selection when navigating Grid
dgvhEnterToNextRowEh
Go to the next line when you press the VK_ENTER
dgvhTabToNextRowEh
Go to the next line when you press the VK_TAB
dgvhHotTrackEh
Highlight the cell on which the mouse cursor
dgvhRowsIsTabControlsEh
Set grid lines act as a set of individual controls. Ie it is not allowed to
move to the next and previous record using navigation keys. By clicking
on the VK_TAB on the last line of the grid control is transferred to the
next control on the form in the order TabOrder.

Working with TDBVertGridEh component at Design-Time


Working with components TVertDBGridEh is similar to working with the component TDBGridEh.
You throw the component on the form, set the DataSource property to the data source,
sozdetete necessarily static strings (TFieldRows) the appropriate fields of the dataset and
customize displaying of the grid and each row.

A class for setting the global behavior of all the elements and
TDBVertGridEh TDBGridEh project
class TDBAxisGridEhCenter and global functions are declared in the DBAxisGridsEh.pas module
function SetDBAxisGridEhCenter(NewGridCenter: TDBAxisGridEhCenter):
TDBAxisGridEhCenter;
function DBAxisGridEhCenter: TDBAxisGridEhCenter;

They are intended for the implementation of a single point for the modification of certain
features in the DBGridEh and DBVerGridEh components. To change the behavior of all the grids
in the project, write your class and heir of TDBAxisGridEhCenter and registered it once
anywhere in the project by using the next function.
SetDBAxisGridEhCenter(TMyDBAxisGridEhCenter.Create).Free;

The function returns an old class that can be immediately removed.


The methods that can be overridden in TDBAxisGridEhCenter:

procedure EditButtonDefaultAction(); virtual;

Occurs when EditButton is pressed in any editor cell component of any TDBGridEh or
TDBVertGridEh class. You can override this virtual procedure to write your actions when
you click on EditButton. To override the action clicking on the level of the individual grid
use the OnEditButtonDown and OnEditButtonClick event.
procedure EditButtonDefaultActionForImage(); virtual;
Occurs when EditButton is pressed in any editor cell component of any TDBGridEh or
TDBVertGridEh class for Blob field type which is the type of BlobType=ftGraphic.
procedure EditButtonDefaultActionText(); virtual;
Occurs when EditButton is pressed in any editor cell component of any class or
TDBGridEh TDBVertGridEh text field.
procedure FormSystemPopupMenuForColumn(); virtual;
Intended to form the Popup menu that opens when user clicks on when EditButton any
editor cell component of any TDBGridEh or TDBVertGridEh class. In the current
implementation, the procedure is called only for graphic Blob fields.

Using TDBSumList component


Common understanding of TDBSumList.
You can use TDBSumList for totaling records in a TDataSet with visible dynamic changes. Set the
DataSet field in the dataset for which you want to get and write SumListChanged event to take
specific action after TDBSumList has changed. TDBSumList has SumCollection property that
represents a container of TDBSum objects. Every TDBSum object represents an element that
can hold specific aggregation value. FieldName and GroupOperation determine type of
aggregation value, SumValue hold current aggregation value.
TDBSumList is embedded in DBGridEh component, so that all below text in equal degrees
pertains as to TDBSumList component and to TDBGridEh.SumList property.

How it works and why SumList sometimes calculate aggregation


values incorrectly.
Data-aware controls interact with dataset via TDataLink object. TDataLink does not allow to
recalculate aggregation value quickly. For instance when the record is deleted from dataset,
dataset sends deDataSetChange event to all TDataLink objects, same event is sent when the
local filter have been changed. So TDataLink cant define why it gets this event and when it
receives such event then it has to recalculate aggregation values running through whole
dataset, even when if only one record was deleted from dataset. SumList doesnt use these
events and after activation, it reassigns following events of the dataset: OnAfterEdit,
OnAfterInsert, OnAfterOpen, OnAfterPost, OnAfterScroll, OnBeforeDelete, OnAfterClose. This
way allows us to avoid of going through whole dataset when it is not needed. But other
problems may appear, such as:
Assigning these events at runtime. Deactivate SumList before assigning one of the earlier
described events at runtime.
Under some conditions SumList can raise exception of access violation. It can happen when
SumList tries to assign events back to dataset which had been already deleted. Such situation
can appear when SumList (or DBGridEh) and dataset are placed in different forms (or
DataModules). In such situation try to deactivate SumList before the Form or DataModule
which contains dataset is deleted.
SumList can not trace changes in dataset if you use SetRange or ApplyRange methods of
TBDEDataSets. Call SumList.RecalAll after using such methods.
SumList cant trace changes in master dataset for detail dataset but not for BDE datasets. Call
SumList.RecalAll after changing active record in master dataset.
In any other case if you see that under some conditions SumList calculates values incorrectly
call RecalAll method.
If DBGridEh is connected to TMemTableEh then you can show aggregated values in grid using
Aggregated fields of TMemTableEh and no need to use TDBGridEh.SumList properties.
TMemTableEh uses internal methods to calculate Aggregated fields and doesnt reassign
events. See description of TMemTableEh for detail information about Aggregated fields.

Using data-aware edit controls


Common understanding of edit controls.
EhLib has a set of data-aware edit controls to edit data:
- TDBEditEh
Editing text data and other data types that can be predtavlyat to see the text.
-

TDBDateTimeEditEh
Editing data of date or time type.

TDBComboBoxEh
Editing text data with an additional drop-down list to select the values.

TDBNumberEditEh
Editing the data of number type.

TDBLookupComboboxEh
Editing based on drop-down list with the record key values instead of the
displayed value.

TDBMemoEh
Editing multiline text data.

TDBImageEh
Editing graphic data.

TDBRadioGroupEh
Editing data mapping in a set of flags.

TDBRichEditEh
Editing text data with RichText format.

EhLib doesnt have not data-aware version of these controls because every control can work as
in data-aware mode and not in data-aware mode. The base class for every edit control is
TCustomDBEditEh. TCustomDBEditEh encapsulates the behavior that is common for all edit
controls for editing text and if it is required for editing a DataSets field by introducing methods
and properties that provide:
-

Basic text editing functions such as selecting text, modifying selected text, and case
conversions.
Properties for making it read-only or introducing a password character to hide the actual
value.
Validity checking using an edit mask.
Writing edited text to database field.

Showing one or several edit buttons (with variable glyphs: dropdown arrow, Ellipsis
arrow, up-down arrows, plus sign, minus sign or custom bitmap) at right part of edit
box,
Showing image from image list at the left part of the edit box.

Application can use Text (String type) and Value (Variant type) properties to get and set string
or variant values to controls. Text property is a text that you can see in control. Value property
hold value of variant type and can hold values of types depending of control type. It can hold
Null value or:
String type value for TDBEditEh and TDBComboBoxEh,
TDateTime, TDate, TTime, Double type value for TDBDateTimeEditEh,
All numeric types value for TDBNumberEditEh,
TDBLookupComboboxEh control hold value that depends on type of the field.
If control is connected to the field then the assignment data to the Text or Value properties
automatically write data to the field.
Every control has Flat and AlwaysShowBorder properties to control the border appearance.

All controls have EmptyDataInfo property that allows customize


edit control to draw special text and font when control have no
data (Edit1.Text = ).

Dynamics properties in components - DynProps.


DynVarsEh is declared in a module class TDynVarsEh which implements a dynamic collection of scalar
variables. Property of the type declared in the component can store a collection of named dynamic set
of variables.
Property type TDynVarsEh is declared with the following components and classes:
TDBGridEh.DynProps
TColumnEh.DynProps
TDBEditEh.DynProps
TDBDateTimeEditEh.DynProps
TDBComboBoxEh.DynProps
TDBNumberEditEh.DynProps
TDBCheckBoxEh.DynProps
Collection TDynVarsEh generated from class TCollection. In Design-Time can create the elements
of the type TDynVarEh with the following properties:
public
property AsBoolean: Boolean;
property AsCurrency: Currency;
property AsDateTime: TDateTime;
property AsFloat: Double;
property AsInteger: LongInt;
property AsRefObject: TObject;
property AsString: String;
property IsNull: Boolean;

published
property Name: String;
property Value: Variant;
In Run-Time collection items can be created dynamically by assigning values.
When reading a collection of values (DBEditEh1.DynProps ['Var1'].Value), if the item in the
collection named 'Var1' is present in the list, it returns the value of the variable. If the element name is
not present, it returns the value Unassigned.
When assigning values, the algorithm checks for the item in the collection.
DBEditEh1.DynProps ['Var1'].Value: = 'StrValue1';
If the item named 'Var1' isnt in the list, a new element is created in the collection and is assigned
with the specified value.

Working with edit buttons


All editing control, as well as columns (For DBGridEh) and TFieldRow (For DBVerGridEh)
contains two properties - EditButton and EditButtons.
EditButton specifies parameters for editing buttons. The buttons
are displayed in the editing or editing control within the grid cell.
To activate a button, use the property EditButton. If the control
is necessary to have some buttons, create additional editing
buttons collection EditButtons.
The class TEditButtonEh added property - DefaultAction.
This class is used in components for TColumnEh DBGridEh,
TFieldRowEh for DBVertGridEh, DBEditEh.EditButtons [i], DBNumberEditEh.EditButton,
DBNumberEditEh.EditButtons [i], DBDataTimeEditEh.EditButton,
DBDataTimeEditEh.EditButtons [i].
It specifies whether you want to perform a default action when
you press the EditButton. Default actions depend on the
component. For example, DBNumberEditEh default action is - the
opening of a drop-down calculator. The other components of this
will be another popup window for editing values. DefaultAction
established in False, you cancel the opening of the pop-ups or
other action by default.
You can write event handler on the mouse down click or mouse click of an Edit button. To do
this, write an event handler or OnButtonDown OnButtonClick konrolya for editing. For
TColumnEh (For DBGridEh) or TFieldRow (For DBVerGridEh) events have names
OnEditButtonDown and OnEditButtonClick. If you create a button through a collection
EditButtons, then write event of a collection TEditButtonsEh: TEditButtonEh.OnClick
TEditButtonEh.OnDown.

To adjust the display of edit button, use the following properties

TDBGridEh.ColumnDefValues.AlwaysShowEditButton The property specifies whether


to display the edit button in the grid constant. The value of a property applies to all the
columns of the grid.
TColumnEh.AlwaysShowEditButton Specifies whether to display the edit button in the
grid constant for a given any column.
TDBGridEh.EditButtonsShowOptions Specifies additional parameters map editing
buttons
when
TDBGridEh.ColumnDefValues.AlwaysShowEditButton
=
True
or
TColumnEh.AlwaysShowEditButton = True. EditButtonsShowOptions property can contain the
following values:
sebShowOnlyForCurCellEh
Display the edit button for the current cell in
the grid
sebShowOnlyForCurRowEh
Display the edit button for the current
record in the grid
sebShowOnlyWhenGridActiveEh Display edit buttons only when the grid has
input focus
sebShowOnlyWhenDataEditingEh - Display edit buttons only when the DataSet
is in edit mode.
The class contains the following properties TEditButtonEh:
Property Name

Property Type

Description

Action

TBasicAction

An instance of TBasicAction or the heir of him.


Components such as Action created in the DesignTime using components TActionList. By assigning
component Action property TEditButtonEh.Action
he will be called by clicking on the edit button.

DefaultAction

Boolean

Specifies whether to call a default action when


user press the button. The default action depends
on the type of field TColumnEh.Field.

DropdownMenu

TPopupMenu

If you set this property PopupMenu component


type drop-down menu that will be displayed
when you click on the Edit button.

DropDownFormParams

TDropDownFormCallParamsEh

It allows you to configure a button to display a


drop-down form DropDownForms.

Enabled

Boolean

Buttons available for press

Glyph

TBitmap

The picture to be displayed on the button

Hint

String

Tip to be displayed when you hover over the


button.

Images

TEditButtonImagesEh

Tip to be displayed when you hover over the


button....

NumGlyphs

Integer

Number of pictures in the Glyph

ShortCut

TShortCut

The combination of buttons that will be triggered


by pressing a button on the keyboard

Style

TEditButtonStyleEh

Style drawing edging buttons


DropDown, Ellipsis, Glyph, UpDown, Plus, Minus,
AltDropDown, AltUpDown

Visible

Boolean

The button is visible

Width

Integer

Width of the button

Working with lists MRUList (last entry list)


All editing control, as well as classes in the grid columns TColumnEh (For DBGridEh) and
TFieldRow (For DBVerGridEh) contain a MRUList property.
This feature is designed to manage a list of the last entries. When you start typing in a text
editor, the system displays a list of recently entered values and offers to choose from a list of
one of the values to not gain it fully again.
MRUList starts only after activation. To activate MRUList set MRUList.Active property to True.
You can complete the list of initial values, using the MRUList.Items
property of TStrings type. When MRUList active and filled the Items
property values, the text editor will display a special list editor under
control, offering to choose one of the existing values list. At the same
list of values will be limited to only those lines, the values that begin
with the string contained in the editor. For a complete list of values, delete the text in the
editor and press VK_BACK.
The property is of type MRUList TMRUListEh and contains the following properties:
property AutoAdd: Boolean
Automatically adding new value to the list when losing focus kontrolom text
input.
property Active: Boolean
MRUList active
property CaseSensitive: Boolean
Search and filter text in the list of sensitive of case
property Items: TStrings
List of Values
property Limit: Integer
The maximum number of rows in the list. After reaching the limit value
monitoring will delete the oldest value prior to the addition of new.
property Rows: Integer
The size of the list box. The size is given in text strings.

ControlLabel - signature for the "control" data editing

The TDBEditEh, TDBNumberEditEh, TDBComboBoxEh, TDBMemoEh, TDBLookupComboboxEh,


TDBImageEh, TDBRichEditEh components are added ControlLabel property the text next to
the editing control. ControlLabel a class of type TLabel, which retain their position on the
master control when moving the control to which it is attached. The combination of TDBEditEh
+ ControlLabel built on the principle of a standard control - TLabeledEdit.
Default
ControlLabel
not
visible.
To
make
ControlLabel
visible
set
EditControl.ControlLabel.Visible property to True.
If EditControl is tied to the database field, it displays the title ControlLabel field of
Field.DisplayName property.
To adjust the location of ControlLabel use subproperties of ControlLabelLocation property:
property Position: TLabelPositionEh
position relative to the master control.
TLabelPositionEh = (lpAboveLeftEh, lpAboveCenterEh,
lpAboveRightEh, lpBelowLeftEh, lpBelowCenterEh,
lpBelowRightEh, lpLeftTopEh, lpLeftTextBaselineEh,
lpLeftCenterEh, lpLeftBottomEh, lpRightTopEh,
lpRightTextBaselineEh, lpRightCenterEh, lpRightBottomEh);
property Spacing: Integer
offset from the master control for the first axes.
property Offset: Integer
offset relative to the second coordinate axis of the master control.
property LabelSpacingBound: TSpacingBoundEh
Label Sets the border controls with respect to which the measured distance
specified property Spacing.
TSpacingBoundEh = (sbNearBoundEh, sbFarBoundEh);
sbNearBoundEh Spacing the distance is relative to the brink of near-Label control.
sbFarBoundEh Spacing The distance is relative to the far verge Label control.
Below are the typical set of values of ControlLabelLocation subproperties:
ControlLabelLocation.LabelSpacingBound =
sbNearBoundEh
ControlLabelLocation.Spacing = 3
ControlLabelLocation.Position = lpAboveLeftEh
ControlLabelLocation.LabelSpacingBound =
sbNearBoundEh
ControlLabelLocation.Spacing = 3
ControlLabelLocation.Position = lpLeftTextBaselineEh
ControlLabelLocation.LabelSpacingBound =
sbFarBoundEh
ControlLabelLocation.Spacing = 80

ControlLabelLocation.Position = lpLeftTextBaselineEh

Using TDBDateTimeEditEh control.


TDBDateTimeEditEh represents a single-line date or/and time edit control that can display and
edit a date or/and time values.
Property Kind determines whether the component is a date editor or/and a time editor
(dtkDateEh, dtkTimeEh, dtkDateTimeEh) or custom date-time mask editor (dtkCustomEh).
Use EditFormat property to set custom date/time format. You can use next format elements:
'YY', 'YYYY', 'MM', 'DD', 'HH', 'NN', 'SS'.
By default TDBDateTimeEditEh build edit mask using ShortDateFormat variable. Edit mask can
be by six types: three for four-char year - 'MM/DD/YYYY', 'DD/MM/YYYY', 'YYYY/MM/DD' and
three for two-char year 'MM/DD/YY', 'DD/MM/YY', 'YY/MM/DD'.
Application can use Text (String type) and Value (Variant type) properties to get and set
DateTime type value in TDBDateTimeEditEh. If TDBDateTimeEditEh has dtkDateEh type then it
will change only date part of the field. If TDBDateTimeEditEh has dtkTimeEh type then it will
change only time part of the field.

Using TDBNumberEditEh control.


TDBNumberEditEh represents a single-line number edit control that can display and edit
numeric values.
TDBNumberEditEh builds display text using DisplayFormat property and shows display text
when control is not active.
Use properties of EditButton object to customize the edit button on the right side of edit
control. When EditButton in UpDown style, the control will work as a Spin edit. Use Increment
property to specify the value that is added or subtracted from Value when the user calibrates
the control.

Using TDBComboBoxEh control.


TDBComboBoxEh component is an edit box with a scrollable drop-down list attached to it. User
can select an item from the list or type it directly into the edit box.
TDBComboBoxEh permits a single line and multiple line of text. Use WordWrap property to set
TDBComboBoxEh as multiple line editor.
Use Items property to access to the list of items (strings) in the list portion of the combo box.
Use KeyItems property to access to the list of items (strings) which will be stored in field when
Items property is also assigned. When Items and KeyItems properties are filled, then KeyList
property have to contain values which will be written in the field, but Items property, in
corresponding indexes, has to contain values to display.

Use Images property to specify images that will be drawn in the drop-down list and image that
will be drawn on the left side of ComboBox. Index of drawing image is taken from ItemIndex
property.
TDBMemoEh control
The component is designed for editing multi-line text data.
The component can operate in Data-aware mode (connected to DataSet) and not in a simple
Data-aware mode.
Properties and methods of the component are similar to those of standard components
TDBMemo.
In addition, the component contains the following additional features:
- AlwaysShowBorder
- DynProps
- EditButtons
- EmptyDataInfo
- Flat
- HighlightRequired
- Images
- MRUList
- Tooltips
When you click on the Edit button, the default form opens DropDown for text editing.
TDBImageEh control
The component is intended for storing and displaying graphical information in a format
Bmp, Png or Gif.
The component can operate in Data-aware mode (connected to a DataSet) and not in a simple
Data-aware mode.
Properties and methods of the component are similar to those of standard components
TDBImage.
In addition, the component contains the following additional features:
- AlwaysShowBorder
- DynProps
- EditButtons
- EmptyDataInfo
- Flat
- HighlightRequired
- Images
- MRUList
- Tooltips
When you click on the Edit button, the default form opens DropDown image editing.
TDBRadioGroupEh control

The component is a set of selection flags (radiobuttons).


The component can operate in Data-aware mode (connected to a DataSet) and not in a simple
Data-aware mode.
Properties and methods of the component are similar to those of standard components
TDBRadioGroup.
In addition, the component contains the following additional features:
DynProps
TDBRichEditEh control
The component is designed for editing multi-line text data with the ability to format
(RichText).
The component can operate in Data-aware mode (connected to a DataSet) and not in a simple
Data-aware mode.
Properties and methods of the component are similar to those of standard components
TDBRichEdit.
In addition, the component contains the following additional features:
- AlwaysShowBorder
- DynProps
- EditButtons
- EmptyDataInfo
- Flat
- HighlightRequired
- Images
- MRUList
- Tooltips
When you click on the Edit button, the default form opens DropDown to edit Rich Text.

Using TDBLookupComboboxEh control.


TDBLookupComboBoxEh represents a combo box that identifies a set of field(s) values in one
dataset with a corresponding set of values from another dataset. To understand 'lookup'
concepts see Delphi help, Topic - Displaying and editing data in lookup list and combo boxes.
TDBLookupComboboxEh can be of two styles (Style property):
csDropDownEh - Application can assign and users can type text which does not contain in data
list.
csDropDownListEh - Application can assign and users can type text which is only present in data
list.
If KeyField, ListField, ListSource, DataField and DataSource properties are empty then you can
assign KeyValue and Text values which doesn't affect each other.
Drop down window takes values from dataset that determines by ListSource property.
Drop down list can:
Show titles (Captions is took from Field.FisplayLabel property),
Show special non-scrolled row in top part of list (SpecRow propery).

Have sizing grip (Sizable property),


Automaticaly set width of window as sum of DisplayWidth of the list fields (Set Width
propery = -1),
Automaticaly drops when user presses any key (AutoDrop property).
Have specified width (Width property).

Using SpecRow in columns of DBGridEh component and in


DBLookupComboBoxEh component.
The SpecRow property of TDropDownBoxEh or DropDownSpecRow property of TColumnEh
holds a TDropDownBoxEh object. TDropDownBoxEh defines attributes of the special row in the
dropped down box. TSpecRowEh represents a special row in the top part of dropdown box for
lookup fields in column of DBGridEh and in TDropDownBoxEh class of TDBLookupComboboxEh
component. This row will be active when lookup field or LookupComboBox has value that is
equal to SpecRow.Value property.
TSpecRowEh contains next properties:
CellsText: String

Specifies the text(s) that will be shown in the drop-down window


for SpecRow. When dropdown box have more than one columns,
use semicolon to separate text for each column.
Color: TColor
Background color of special row in dropdown box.
Font: TFont
Font of special row text.
Value: Variant
Value. Special row is shown as selected (highlighted) when this
Value is equal to value of control to which this special row belong
to.
Visible: Boolean
Specify, whether the spec row is active and visible in the DropDown
box.
ShortCut: TShortCut Specify the shortcut for assigning value of SpecRow.Value property
to Control value.
ShowIfNotInKeyList: Specify, whether the SpecRow text will be shown in Control if the
Boolean
value of the control is not in list of key values.

DropDownForms - custom drop-down windows


Typical DropDown window - is a list that appears in the control TComboBox when you click on
the edit button.
New technology allows you to create a customizable drop-down windows that appears when
user click on the button (EditButton) in TDBEditEh, TDBNumberEditEh, TInplaceEditor in
DBGridEh etc. components.

Follow next steps to create and use a DropDown Form:


1. Create a Form that is inherited from TCustomDropDownFormEh class.
This can be done at Design-Time through the menu File-New-Other ...-Tab "EhLib Forms""DropDown Form" item.
2. Create and arrange controls on the Form.
3. Write Form event handlers:
OnInitForm event - to get the parameters passed from the text editor and initiate the
form according to the received parameters.
OnReturnParams event - to store the selected value from the Form to the internal
structure for the subsequent transmission to a text editor.
4. It is necessary to assign the property DropDownFormParams.DropDownForm or
DropDownFormParams.DropDownFormClassName in a text editor or edit button (TDBEditEh,
TDBNumberEditEh, DBGridEh.TColumnEh), where are you going to call the DropDown Form, to
indicate which Form should be called when a user clicks on the edit button.
This is a sufficient minimum set of steps to make DropDown Form work at Run-Time.
By default, the text editor transmits the value as the first parameter in the Form and writes the
resulting value of the first parameter transmitted from the From to itself text property.
Lets look at the steps of creating a DropDown Forms with more details.
Step 1 - Creating a DoprDown Form class.

When creating a Form through menu menu File-New-Other ...-Tab "EhLib Forms"-Element
"DropDown Form" a system call a library code that creates a new Form that is inherited from
CustomDropDownFormEh class.

Step 2 and 3 - Placing a components on the form and writing event handlers.
At Run-Time, working with a Form resembles working with a dialog box in a ShowModal mode.
However, the system closes the DropDown Form when the form loses it active state. You can
also close the form in the code indicating that the Form must be closed with a "Send the
selected value to the calling control" indication. In this case the event in the edit control would
be caused to store the selected value. You can also customize that the edit control assigns a
selected value to itself automatically.
The Library calls an TCustomDropDownFormEh.OnInitForm event before showing the Form. It is
necessary to initialize the Form before displaying and use the transferred data from the caller
control.
Here is an example of event handler for OnInitForm event:
procedure TDropDownMemoEdit1.CustomDropDownFormEhInitForm(
Sender: TCustomDropDownFormEh; DynParams: TDynVarsEh);
begin
if DynParams.Count >= 1 then
Memo1.Lines.Text := DynParams.Items[0].AsString;
sbOk.Enabled := not ReadOnly;
Memo1.ReadOnly := ReadOnly;
end;

In the above code the check is performed, whether any value was transferred from the Control
through the DynParams parameter. If it was transferred, the value is assigned to a Memo1.
DropDown Form may be in of ReadOnly. This property is assigned by the transmission control
depending of Control.Field.ReadOnly value. In the above code, we adjust components of the
form according to the state ReadOnly. Consider that a ReadOnly form will not return any value,
and will only be opened to view the data.
Closing the Form and transferring the selected values
Assign ModalResult property by mrOk to close the Form with the "Transfer selected value"
indication.
Below is a code sample that closes the Form:
procedure TDropDownMemoEdit.sbOkClick(Sender: TObject);

begin
ModalResult := mrOk;
Close;
end;

The program will close the Form and call OnReturnParams event to transfer the selected values
in the internal variables.
By default, the system offers to write the selected values in the DynVars array that is passed as
a parameter.
Below is an example of an OnReturnParams event handler:
procedure TDropDownMemoEdit1.CustomDropDownFormEhReturnParams(
Sender: TCustomDropDownFormEh; DynParams: TDynVarsEh);
begin
DynParams.Items[0].AsString := Memo1.Lines.Text;
end;

In our case, we write the text from a TMemo to the first item of a DynParams collection. The
collection will already contain an element, as we have already passed it in the Form using the
same collection (This part will be discussed later in the part of customizing the edit control).
TCustomDropDownFormEh.FormElements property
TCustomDropDownFormEh class has a property to define of displaying additional special
controls on the Form. Use FormElements property to specify which additional items have to be
placed on the Form in the Run-Time:
ddfeLeftGripEh SizeGrip control in the left corner. This element is used to change a
window size.
ddfeRightGripEh SizeGrip element in the right corner of the window.
ddfeCloseButtonEh Close button.
ddfeSizingBarEh The bar at the bottom of the window to change the height of the
window by mouse.

Step 4 Customizing the calling controls.


There are a DropDownFormParams property in the classes that work with text editors, such as
TColumnEh, TDBEditEh etc.,. This property contains sub-properties to configure a DropDown
Form: to define which form must be shown, how to pass and get parameters to/form the From.
Use the property DropDownFormParams.DropDownForm or DropDownFormParams.
DropDownFormClassName to specify the name of the form to be displayed when a user clicks
on the EditButton.

If DropDownFormParams.DropDownForm property is assigned then the Form must be created


in advance and assigned to a global variable <DropDownFormName: TDropDownFormName>,
which is created by the project code when creating forms. This creation and assignment occurs
automatically when the form is in the list of Auto-create forms (see Project properties).
If DropDownFormParams.DropDownFormClassName property is assigned then the program will
create a form just before showing and destroy it after the Form is closed. To allow the program
to find the form designer by the name of the class, form class must be registered using
procedure Classes.RegisterClass.
This can be done in the initialization part of DropDown Form unit.
Below is an example of registering a class:
unit MyDropDownFormUnit1;

interface

initialization
RegisterClass(TMyDropDownForm1);
end.

There is another way to create a DropDown Form. Form is created before the first display and
lives up to the end of the life of the program.
To implement this method follow the next steps:
- Assign the DropDownFormParams.DropDownFormClassName property
- Register the class of the Form using RegisterClass (TMyDropDownForm1) code.
- Override the virtual class function TCustomDropDownFormEh.GetGlobalRef:
TCustomDropDownFormEh to create Form on the first call and assigns it to a global
variable.
Below is the sample of code that implements this functionality:
type
TDropDownMemoEdit3 = class(TCustomDropDownFormEh)

public
class function GetGlobalRef: TCustomDropDownFormEh; override;
end;
var
DropDownMemoEdit3: TDropDownMemoEdit3;
implementation

class function TDropDownMemoEdit3.GetGlobalRef: TCustomDropDownFormEh;


begin
if DropDownMemoEdit3 = nil then
Application.CreateForm(TDropDownMemoEdit3, DropDownMemoEdit3);
Result := DropDownMemoEdit3;
end;

end.

Step 4.1 Assigning parameters from edit control the DropDown Form.

Use DropDownFormParams.PassParams property to specify which field values must be passed


in the drop-down Form. The property can hold one of the next values:
pspByFieldNamesEh - Pass the value of the fields specified in the property
DropDownFormParams. PassFieldNames
pspFieldValueEh - Pass the current value of the edit control.
pspRecordValuesEh - Pass the value of all the fields of the current DataSet record.
In the drop-down form, you can read the transferred value form DynParams collection.
DropDownFormParams property contains the following sub-properties:
Property Name

Property Type

Description

DropDownForm:

TCustomForm

Reference to a DropDown Form.

DropDownFormClassName: String

Reference to a class that implements


DropDown Form.

Align:

TDropDownAlign

Alignment of the DropDown Form


relative to the edit control.

PassParams:

TDropDownPassParamsEh Way of passing the parameters.

PassFieldNames:

String

The name of the DataSet fields, the


value of which should be passed in
the Form.

AssignBackFieldNames:

String

The name of the DataSet field, the


value of which assigned to the values
received from the Form.

FormWidth:

Integer

Width of the Form. The Form width


is written to the property when the
Form is closed.

FormHeight:

Integer

The height of the form. The Form


height is written to the property
when the Form is closed.

SaveFormSize:

Boolean

The property determines whether to


keep the size of the form in the
FormWidth and FormHeight
properties.

Example of using DropDown forms:


Examples of using and working with DropDownForms see at the Demo Project:
<EhLib Archive>\Demos\DropDownForm\Project1.dpr
compiled project:
<EhLib Archive>\Demos\Bin\DropDownForm.Exe
New properties in classes of the library for working with DropDown Forms:
New properties to customize the display drop-down forms appeared in the next classes:
(For DBGridEh)
TColumnEh.DropDownFormParams
TColumnEh.EditButtons[i].DropDownFormParams

(For DBVertGridEh)
TFieldRowEh.DropDownFormParams
TFieldRowEh.EditButtons[i].DropDownFormParams
TDBEditEh.EditButton.DropDownFormParams
TDBEditEh.EditButtons[i].DropDownFormParams
In EditButtons for TDBNumberEditEh, TDBDateTimeEditEh, TDBComboBoxEh,
TDBLookupComboBoxEh controls.

View properties of components at Run-Time


When using the library it is possible to call a special Form of Object Inspector type. This form
can be used to debug the component at run time by changing the values of the component
properties.

To start using the form, add the unit


ObjectInspectorEh in the Uses section of your module
and
call
the
global
procedure
ShowObjectInspectorForm.

The procedure shows a Form with a list of properties


the explored component in the same manner as
Design-Time Object Inspector. You can use it to
configure the properties of the components at RunTime.

The procedure has the following parameters:


procedure ShowObjectInspectorForm(
Component: TObject; // Component to inpsect
FormBounds: TRect; // Bounds of the Form
NewForm: Boolean = False // Show as a new Form
);

Using TPropStorageEh and TPropStorageManagerEh


components
TPropStorageEh and TPropStorageManagerEh componetns realize technology to store
components properties to/from settings storage such as Ini files, Registry etc.
Current version of library has components to write/read in/from Ini files and Windows Registry.
Base component of this technology is the TPropStorageEh. Place this component in the form,
component properties of which you want to save in the storage. Double click on the
component during the design-time to open properties storage editor window. In the tree of
properties you can select required properties for storing. Properties list is a list of all published
properties or declared in DefineProperty function of components with the exclusion of
TCollection class properties. Besides the list of all elements of the collection, the tree of
properties will contain <ForAllItems> subproperty. When you select sub-property in the given
branch, the component will save corresponding sub-property for each element of the
collection.
Component TPropStorageEh can write and read property values in the stream. To redirect flow
in the storage it is necessary to execute one of the following actions:
1. Place component that is inherited from TPropStorageManagerEh on the form.
In this version there are two such components. These are TIniPropStorageManEh and
TRegPropStorageManEh.
Customize properties of this component and assign component to
TPropStorageEh.StorageManager property.
2. Or you can only once write code to register global component - DefaultPropStorageManager.
All TPropStorageEh components, in which StorageManager property is not assigned, will use
DefaultPropStorageManager manager for redirecting flow of the property values to the
storage.
Code to register global store manager can look like this:
----------- MainUnit.Pas-------......
var
IniPropStorageMan: TIniPropStorageManEh;
initialization
IniPropStorageMan := TIniPropStorageManEh.Create(nil);
IniPropStorageMan.IniFileName := 'MyIniFile.Ini';
SetDefaultPropStorageManager(IniPropStorageMan);
end.
--------------------------------

Introduction in technology of interaction between MemTable


and DataDriver.
This technology is intended for unified way of loading tabular information from the server to
the client with afterward processing these data on the client: editing, sorting, filtrations and
unloading changed data back to the server. This technology doesnt include drivers to access
server but it have a set of components and global events to redirect flow of data to/from server
using your favorite access engine.
The technology is represented by two main components:
TMemTableEh - is a dataset that hold data in memory. Its possible to consider it as an array of
records.
Besides, this dataset:
Supports a special interface, which allows DBGridEh component to view and scroll data
without moving active record.
Allows to fetch data from TDataDriverEh object (DataDriver property).
Allows to unload changes back to DataDriver, instantly or postponed (in dependencies of
the CachedUpdates property).
Allows to create a master/detail relations on the client (filtering record) or on the external
source (updating parameters [Params] and requiring data from DataDriver).
Allows to sort data, including Calculated and Lookup field.
Allows to work in standalone mode. Allows to create structure and fill data at design-time
and save data in DFM file of the Form (When DataDriver property is not assigned).
Allows to keep record in the manner of trees. Each record can have records-branches and it
itself can be an element to other parental record. TDBGridEh component supports to show the
tree-type structure of these records.
Allows to connect to the internal array of other TMemTableEh (via ExternalMemData
property) and work with its data: sort, filter, edit.
Has interface for requesting list of all unique values in one column of records array, ignoring
local filter. TDBGridEh uses this property for automatic filling a list in DropDownBox of the
subtitle filter cell.
TDataDriverEh - carry out two tasks:
1. Delivers data to TMemTableEh.
2. Processes changed records of TMemTableEh (writes them in other dataset, or call
events for processing the changes in program for passing updates to the server).
Furthermore, there are several components that are inherited from TDataDriverEh. These are a
TSQLDataDriverEh, that have properties to keep five SQL expressions and parameters to: query
data, delete record, insert record, update record and require one record. TSQLDataDriverEh
cant interact with server by itself, but can prepare parameters for request and can call global
event to transfer SQL expression for processing in application. There are several components
which are inherited from TSQLDataDriverEh and which can send SQL expressions to the server
through the corresponding access engine. These are TBDEDataDriverEh, TIBXDataDriverEh,
TDBXDataDriverEh and TADODataDriverEh components.

TMemTableEh component.
Two working mode of TMemTableEh component.
There are two working mode of TMemTableEh: stand-alone and with datadriver.
stand-alone mode.
In stand-alone mode TMemTableEh works as independent array of data. Before
working with such MemTable it is necessary to create an internal structure of record. For that it
is necessary to create external fields (TFields) or field definitions in TMemTableEh and call
CreateDataSet method (Or, at design-time, press Create DataSet button in Fields editor
window).
'with datadriver' mode.
The 'with datadriver' mode is activated when TMemTableEh.DataDriver property is assigned.
Internal array is created automatically on activation of MemTableEh. Structure of the fields is
delivered by DataDriver component.

ViewScroll
TMemTableEh supports special interface, allowing DBGridEh component to view all data
without moving active record. We will call such state as ViewScroll.

Master/detail relations.
Master/detail relation is a working mode of two datasets when all visible records of one dataset
(DetailDataSet) always correspond to one record of other dataset (MasterDataSet). In time of
moving in MasterDataSet the DetailDataSet will recreate or filters records so that they will
correspond to MasterDataSet record. The correspondence is adjusted using MasterFields and
KeyFields properties of DetailDataSet. DetailDataSet always show only the records, which
values of the field/fields defined by MasterFields property is equal to values of the fields
defined by MasterFields property of the current record of MasterDataSet.
TMemTableEh allows to create a master/detail relations on the client side "mdsOnSelfEh" (by
filtering record) or on DataProvider "mdsOnProviderEh" (by recreating list of records in
DetailDataSet when record in MasterDataset is changed).
To adjust TMemTableEh in the master/detail mode use next properties: MasterSource,
MasterFields, KeyFields, MasterDetailSide. When MasterDetailSide is
mdsOnSelfEh,
TMemTableEh will filter records by DetailFields fields using values of
MasterDataSet[MasterFields] fields. When MasterDetailSide is mdsOnProviderEh,
DetailDataSet will reopen itself, assigning parameters from MasterDataSet[MasterFields]. On
opening it will pass parameters to DataDriver. In the mdsOnProviderEh mode the DetailFields
are not used.
The third state of working "mdsOnSelfAfterProviderEh" is a combination of two preceding.
Upon first moving to record in MasterDataSet the DetailDataSet gets records from DataDriver,
sending him parameters with values, assigned from MasterSource[MasterFields] and add
received records in its internal array of record. Upon next moving on same record in
MasterDataSet the DetailDataSet will always only filter records locally.

Working with AutoIncrement fields


TMemTableEh has an AutoIncrement property with InitValue and Step subproperties to work
with fields which values are generated by automatic sequence numbers. For such fields
property TField.AutoGenerateValue mast be arAutoInc. Values for such fields are generated
automatically using internal counter when the new record is appeared in the internal array.
Initial value of the counter is assigned by the TMemTableEh.InitValue property. After inserting
new record, a value of the counter increases on the number given by the TMemTableEh.Step
property.
If TMemTableEh is connected to DataDriver then usually values of such fields are generated by
the server. To cause TMemTableEh be able to get values of fields generated by the server, it is
recommended to use TMemTableEh and TSQLDataDriver (or inherited from it) as follow:
Set InitValue property and Step property to -1. Values of AutoIncrement fields will have
negative values before sending the new record to the server.
Add parameters in TSQLDataDriver.SpecParams property to make SQLDataDriver be able to get
values of AutoIncrement fields generated by the server. List of parameters in
TSQLDataDriver.SpecParams depends on the type of Server and will be described later. After
updates are applied and record new writes to the server, SQLDataDriver will request new value
of the counter from server and assign it to the AutoIncrement field on the client.

Using indexes.
Indexes are used for speeding up searching. In particular it is used to building a tree-type
structure of records. Pattern of indexes is assigned in IndexDefs collection. TMemTableEh
creates indexes basing on the pattern when it making an internal array of records. It usually
happens when DataSet is activated).

Using shared array of records by several TMemTableEhs.


TMemTableEh allows to use a same array of records by several TMemTableEh components.
But only one main TMemTableEh must be holder of the array. Others will connect to this array
using ExternalMemData property use it. Other TMemTableEh components access external data
of the main TMemTableEh ignoring local filter of main TMemTableEh. DataDriver property can
be assigned only for main MemTable. Sorting and filtration in each MemTableEh components
dont affect to each other.

Moving records in TMemTableEh when dghRecordMoving mode is


active.
Include dghRecordMoving in OptionsEh of DBGridEh component to allow users moving records
inside TMemTableEh component. Besides, when TreeList mode is active, DBGridEh allows move
records inside tree by changing records and level of node. To move record at run-time, a user
has to press the mouse button above the indicator of record and drag it to required place inside
the grid (when multiselect is active user has to select records to move before dragging).

TRefObjectField field type.


MemTableEh unit have code to register new type of field - TRefObjectField. TRefObjectField is
intended to keep the pointer to TObject type object and have Value property of TObject type.
At design-time choose RefObjectField type in form of creating new field to create
TRefObjectField field. At run-time in the program you can create a field of this type by assign
ftUnknown value to DataType property of FieldDef object.

Using maintained aggregates


MemTableEh provide support for summarizing data over all records of DataSet.
MemTableEh keep aggregated values (such as SUM, COUNT) in TAggregateField field type. At
Design-time mode use Fields Editor to create persistent aggregated field. You can bind such
fields to TDBEditEh component or to the footer of TDBGridEh.

Records sorting.
TMemTableEh has two methods of the sorting: Sorting with dynamic supporting of the changes,
when the added record is automatically move to the necessary position to support order of the
sorting.
And sorting without dynamic supporting of the changes.
1.
Use the SortOrder property to sort data with dynamic support of the changes. Separate
several fields by comma. Add DESC after fieldname to sort data in inverse sequence. Sorting
occurs at the TRecordsViewEh object, so physically the records doesnt move inside internal
array TRecordsListEh.
2.
Use SortByFields procedure to sort data without dynamic support of the changes. The
string that define sorting must have same format as for SortOrder property. Sorting occurs on
the level of TRecordsListEh, i.e. records are sorted physically in the internal array of data.
When you use EhlibMTE unit for automatic sorting in DBGridEh you can use global variable
SortInView of Boolean type to define the type of sorting that will be executed when DBGridEh
performs sorting after sorting markers in titles of grid are changed.

Creation/removing table data in memory in the stand-alone mode.


MemTableEh allows to create an internal array of records at design-time and at run-time.
Before creating the table data, you need to set properties to specify the structure of the table
you want to create. In particular, you need to specify structure of the fields of the new array.
There are two ways to do this:
First way, you can add field definitions to the FieldDefs property. At design time, double-click
the FieldDefs property in the Object Inspector to bring up the collection editor. Use the
collection editor to add, remove, or change properties of field definitions. At runtime, clear any
existing field definitions and then use AddFieldDef method to add each new field definition. For
each new field definition, set the properties of the TFieldDef object to specify the desired
attributes of the field.
Second way, you can use persistent field components instead. At design time, double-click on
the dataset to bring up the Fields editor. In the Fields editor, right-click and choose New Field
command. Describe the basic properties of your field. Once the field is created, you can alter its
properties in the Object Inspector by selecting the field in the Fields editor.
After creating field definitions or persistent fields, you need to create internal array. At Designtime mode, click right mouse above dataset and choose 'Create DataSet'. This command does
not come up in the context menu until you define the whole necessary information.
To create an internal array at Run-time, you need to call CreateDataSet method.
If DataDriver property is assigned then internal array will be created automatically on
activations MemTable. At this case the structure of array MemTable get from DataDriver.

In stand-alone mode when MemTable is closing it does not delete internal array of records.
To close MemTable with simultaneous deleting of all records and structure, use DestroyTable
method.
Use EmptyTable method to delete all records from MemTable.

Working with MemTableEh in the 'with datadriver' mode.


If TMemTableEh.DataDriver property is assigned then MemTable works in 'with datadriver'
mode. In this case internal array will be created automatically when MemTableEh become
active. The structure of array is delivered by the DataDriver component.
If FetchAllOnOpen property is True then MemTableEh loads all records from DataDriver on
open. If FetchAllOnOpen is False then MemTableEh will not load records until application call
Next or FetchRecords methods. Method Next checks that cursor is positioned at end of
MemTableEh, if not then it fetch next record and move to the next record in provider. Method
FetchRecords fetch more records from DataDriver and add it at the end of internal array of
MemTable. This method takes one parameter - an amount of records which need to fetch. To
fetch all record it is needed to pass -1 as parameter. When MemTable connected to DBGridEh
the Grid calls FetchRecords by itself via IMemTableEh interface to display all visible records in
the view area. If CachedUpdates property is False then changes are transferred right after Post
method. If CachedUpdates is True then data are not transferred until the ApplyUpdates method
is called.

Cached updates.
TMemTableEh can work in operative or postpone updates. CachedUpdates property defines type
if updates. In operative mode of the updates, TMemTableEh sends changed record to c right after
application call TMemTableEh.Post method or append new record in TMemTableEh. In the
postpone mode the updates arent sent to postpone, but are accumulated in the special buffer.
Data are not transferred until the client application calls the ApplyUpdates method. To turn on
the postpone updates you need set CachedUpdates property to True.
ApplyUpdates have a single parameter MaxErrors. MaxErrors indicates the maximum number
of errors that the DataDriver should allow before prematurely stopping update operations. Set
MaxErrors to 1 to indicate that there is no limit to the number of errors. Set MaxErrors to 0 to
define that whole process of change will be rejected on first error. Records, which renovations
have come with errors, have an additional UpdateError property with type of TUpdateErrorEh.
To identify type of changing of record you need to use UpdateStatus method and StatusFilter
property:
UpdateStatus indicates a type of changing of current record in MemTable. It returns one of the
following values:
usUnmodified - Indicates that the current record havent been changed.
usModified - Indicates that the record was edited and changed.
usInserted - Indicates that the record was added.
usDeleted - Indicates that the record was removed.
StatusFilter defines filter for different types of records. StatusFilter is a set that can contains
any combination of the following values:
usUnmodified Unmodified records are visible in MemTable.
usModified - Modified records are visible in MemTable.
usInserted - Added records are visible in MemTable.
usDeleted Deleted record are visible in MemTable.

By default, StatusFilter have [usModified, usInserted, usUnmodified] value. So, deleted records
are hidden.
Method RevertRecord restores an old condition of the current record and values of fields. If
record was added in the program, it is deleted from the list. If record was changed then
UpdateStatus property is restored to usUnmodified value.
Method MergeChangeLog deletes a log of cached changes. All added or changed records get
usUnmodified status.
Method CancelUpdates cancels all changes and restores old state of records array.

Marking and Returning to Records.


In addition to moving from record to record in a dataset (or moving from one record to another
by a specific number of records), you can mark a particular location in a dataset so that you can
return to this location. TDataSet introduces a bookmarking feature that consists of a Bookmark
property and five bookmark methods. In TMemTable, bookmarks contain the record number
(RecNo property).
The Bookmark property.
Bookmark gets or sets the current bookmark in a dataset. A bookmark marks a location in a
dataset so that an application can easily return to that location quickly.
An application can read Bookmark to retrieve the bookmark associated with the current record,
and it can change the current record in the dataset by assigning a saved bookmark value to this
property.
GetBookmark method
I do not recommend to use this method, use Bookmark property instead of it. See VCL
documentation for detail.
GotoBookmark and BookmarkValid method
When passed a bookmark, GotoBookmark moves the cursor for the dataset to the location
specified in the bookmark. Before calling GotoBookmark, you can call BookmarkValid to
determine if the bookmark points to a record. BookmarkValid returns True if a specified
bookmark points to a record.
CompareBookmarks method
You can also call CompareBookmarks to see if a bookmark you want to move to is different
from another (or the current) bookmark. If the two bookmarks refer to the same record (or if
both are nil), CompareBookmarks returns 0.
FreeBookmark method
This method is Used in combinations with GetBookamrk. I do not recommend to use this
method. See VCL documentation for detail.

Searching in TMemTableEh
You can search in TMemTableEh using following methods:

1. Locate
Locate moves the cursor to the first row matching a specified set of search criteria. In its
simplest form, you pass Locate the name of a column to search, a field value to match, and an
options flag specifying whether the search is case-insensitive or if it can use partial-key
matching. (Partial-key matching is when the criterion string need only be a prefix of the field
value.) For example, the following code moves the cursor to the first row in the CustTable
where the value in the Company column is "Professional Divers, Ltd.":
var
LocateSuccess: Boolean;
SearchOptions: TLocateOptions;
begin
SearchOptions := [loPartialKey];
LocateSuccess := CustTable.Locate('Company', 'Professional Divers, Ltd.',
SearchOptions);
end;

If Locate finds a match, the first record containing the match becomes the current record.
Locate returns True if it finds a matching record, False if it does not. If a search fails, the current
record does not change.
The real power of Locate comes into play when you want to search on multiple columns and
specify multiple values to search for. Search values are Variants, which means you can specify
different data types in your search criteria. To specify multiple columns in a search string,
separate individual items in the string with semicolons.
Because search values are Variants, if you pass multiple values, you must either pass a Variant
array as an argument (for example, the return values from the Lookup method), or you must
construct the Variant array in code using the VarArrayOf function. The following code illustrates
a search on multiple columns using multiple search values and partial-key matching:
with CustTable do
Locate('Company;Contact;Phone', VarArrayOf(['Sight Diver','P']), loPartialKey);
Locate uses the fastest possible method to locate matching records. If the columns to search
are indexed and the index is compatible with the search options you specify, Locate uses the
index.
2. Lookup
Lookup searches for the first row that matches specified search criteria. If it finds a matching
row, it forces the recalculation of any calculated fields and lookup fields associated with the
dataset, then returns one or more fields from the matching row. Lookup does not move the
cursor to the matching row. It only returns values from it.
In its simplest form, you pass Lookup the name of field to search, the field value to match, and
the field or fields to return. For example, the following code looks for the first record in the
CustTable where the value of the Company field is "Professional Divers, Ltd.", and returns the
company name, a contact person, and a phone number for the company:

var
LookupResults: Variant;
begin
LookupResults := CustTable.Lookup('Company', 'Professional Divers,
Ltd.', 'Company;Contact; Phone');
end;
Lookup returns values for the specified fields from the first matching record it finds. Values are
returned as Variants. If more than one return value is requested, Lookup returns a Variant
array. If there are no matching records, Lookup returns a Null Variant.
The real power of Lookup comes into play when you want to search on multiple columns and
specify multiple values to search for. To specify strings containing multiple columns or result
fields, separate individual fields in the string items with semicolons.
Because search values are Variants, if you pass multiple values, you must either pass a Variant
array as an argument (for example, the return values from the Lookup method), or you must
construct the Variant array in code using the VarArrayOf function. The following code illustrates
a lookup search on multiple columns:
var
LookupResults: Variant;
begin
with CustTable do
LookupResults := Lookup('Company; City', VarArrayOf(['Sight Diver',
'Christiansted']),
'Company; Addr1; Addr2; State; Zip');
end;
Like Locate, Lookup uses the fastest possible method to locate matching records. If the columns
to search are indexed, Lookup uses the index.
3. FindRec
FindRec searches for the first row that matches specified search criteria and return record
number. FindRec have the same parameters as the Locate method.
When MemTableEh is in tree-view mode the Locate and FindRec methods search records in
expanded nodes. To search matches in all nodes you need to use MemTableEh.TreeList.Locate
method. This method also expand founded node, so it will be visible in dataset.

4. GotoRec
GotoRec moves the cursor to the row passed by the Rec parameter. GotoRec returns True if it
finds a record, False if it does not.

Quick access to the record values.


To get values of the fields from specified record in standard DataSet, it is necessary to move to
the required record. This not always suitable since when you move to the record using MoveBy,

RecNo, Bookmark methods calls events about changing the record position that can bring about
big delays and repaint of the screen.
There are several ways in MemTableEh that allow to get values of the fields without activations
record position.
1. You can use DisableControls, EnableControls methods to deactivate events about
changes in DataSet. Disadvantage of this way is that EnableControls causes event about
changes DataSet, that will repaint visual component connected to DataSet.
2. You can use InstantReadEnter, InstantReadLeave methods to enter in InstantRead
mode.
InstantReadEnter enters in mode of viewing records and moves virtual position to the
record determined by the RowNum parameter. After that you can read but dont
change values of record. Each call of InstantReadEnter method, must correspond call
InstantReadLeave. InstantReadLeave leave a viewing records mode. In InstantRead
mode it is not allowed to change values of record. InstantReadEnter and
InstantReadLeave methods do not send events about changing position in DataSet.
3. You can use properties to access internal array of records of MemTableEh. Internal
objects allow to access values of record as to the array of data with index. Besides you
may addresses to all writing an internal array given disregarding local filter. For access
to internal structures of data you need to use following properties of TMemTableEh:
RecordsView: TRecordsViewEh
filtered list of records.
RecordsView.Rec[Index: Integer]: TMemoryRecordEh
access to certain record in filtered list of records.
RecordsView.Count: Integer
Count of records in the filtered list of records. In TreeView mode list have only visible
in expanded nodes.
RecordsView.MemTableData.RecordsList[Index: Integer]:
TMemoryRecordEh
access to certain record in the list of all records.
RecordsView.MemTableData.RecordsList.Count
Count of records in list of all records.
RecordsView.MemTableData.RecordsList[Index:
Integer].DataValues[const FieldNames: string; DataValueVersion:
TDataValueVersionEh]: Variant
access to certain value of field in record specified by Index.
FieldNames parameter specifies the name of the field or list of fields separated by a ";".
In case if FieldNames contains a list of fields, the return value will contain an array of
values.
DataValueVersion parameter defines the "version" or the type of value that should be
returned or assigned. In most cases, the value dvvValueEh can be used, which defines
the current active version of the field value.

In certain cases, the record can contain multiple values for the same field, but the active
value is always only one version, which can be get or put by passing dvvValueEh value
as a DataValueVersion parameter.
Multiple values appear when the record is edited or Post method is called for record
that was received from a server.
Version values can be associated with the kinds of record value buffers. Three buffers
can exist for one record:
1. Buffer of current values. This buffer is created when the record fetches data from a
server.
2. Buffer of editing values. This buffer is created at the moment when the record
changes it state to Editing. Buffer is destroyed when Post or Cancel method is called.
3. Buffer of old (server) record values. This buffer is created after the Post method is
called if the record obtained it initial values from the server. Ones it is written in the
buffer veluse doesnt been changed hereafter. This buffer is used to generate
UPDATE or DELETE SQL statements.
Unconditional versions - are versions that return values from a specific record buffer.
dvvCurValueEh A value from a buffer of current values.
dvvEditValueEh A value from a buffer of editing values.
dvvOldValueEh A value from a buffer of old (server) record values.
Conditional versions - these are versions that return the value of the specified buffer,
depending on the current state of the record:
dvvValueEh If the record is in the Editing and Inserting state, then value from the
buffer of editing values is returned, otherwise it takes values from the buffer of
current values.
dvvOldestValue If a buffer of old values exist then a value from this buffer is returned,
else if a buffer of a current values exist then a value from this buffer is returned,
otherwise, it returns a value from a buffer of editing values.
dvvRefreshValue If a buffer of old values exist then a value from this buffer is
returned, otherwise a value from a buffer of current values is returned.

Copying data from/to another DataSet.


TMemTableEh affords the following methods for copying data from/to another DataSat:
SaveToDataSet method
Copying it own data in another DataSet, specified by Dest parameter. If RecordCount parameter
> 0, the copying begins from current record of source DataSet and copy not more then
RecordCount record. If RecordCount = 0 then all records will be copied. When copying the
MemTable always add records in Dest DataSet.
LoadFromDataSet method
Loads not more then RecordCount records from Source DataSet to itself. If RecordCount = -1
then it load all record. If Mode parameter is lmCopy then all data will be deleted before
loading. If Mode parameter is lmAppend then new records will be added to existing data.
UseIfCachedUpdates parameter define that new records gets usInserted status.

Changes in the structure of the internal array of MemTableEh without


losing data.
In MemTableEh it is added ability to edit the structure of the internal array of records "on the fly" in the
open dataset without losing data in records.
To change the structure in design-time, double-click on the component MemTableEh. In the editing
window, edit the structure of the DataSet data on the tab 'Edit data structure', click ' Apply new
structure to change the structure of the data physically. If you change the field type, MemTableEh
attempts to convert the field values to the new type. If that fails, the field is set to Null.
Following the restructuring, the component MemTableEh rediscovers itself. Be careful when changing
the structure of records when you have fields in MemTableEh created statically (Persistent fields). To
change the structure of the records for the MemTableEh which must be statically created fields: close
MemTableEh, change the structure and make the same changes in the fields (Fields).
To change the structure of the table in the run-time using the following algorithm:
FUNCTIONS BeginRestructure call for a copy of the structure.
Edit the copy of the structure: InsertField, RemoveField, ChangeFieldType.
Call the procedure EndRestructure to apply a new structure to the existing structure and data
records.

Demo:

See the Demo project of using macro variables in your library

archive <EhLib Dir\Demos\ MemTableEh.LifeRestructure>

Save / load data from / to the file (s).


In MemTableEh has the ability to save data to a file and load the data from the file. When
saving data MemTableEh writes the internal structure of the array and writing the array.
procedure SaveToFile(const FileName: string = ''; Format: TDfmStreamFormatEh
= dfmTextEh);
type TDfmStreamFormatEh = (dfmBinaryEh, dfmTextEh);

Writes the contents of the internal FileName dataset components TMemTableEh.

procedure LoadFromFile(const FileName: string = '');

Loads data from a file FileName into the internal data array components TMemTableEh. In this
case, the old structure and the contents of the internal components of the array is removed.

Demo:

An example of using functions to save and load data to / from a file

in the main library of the demonstration project <EhLib_Dir\Demos\MainDemo>

Internal objects of TMemTableEh component.


In most cases to work with data in TMemTableEh it is sufficient to use properties and
methods of the TMemTableEh. However in some cases it is necessary to work with data at low
level. TMemTableEh component keep records in internal array of records and has seven main
objects for processing the internal data:
TMemTableDataEh
Internal table of data. Is have two objects: TMTDataStructEh - describes the
structure of a table fields and TRecordsListEh containes a list of records of
TMemoryRecordEh type.
TMTDataStructEh
Describes structure of a table fields. Is have a list of objects that inherited from
TMTDataFieldEh class.
TMTDataFieldEh
base class that describe field type in internal table array. It is a parent for such types
as TMTStringDataFieldEh, TMTNumericDataFieldEh,
TMTDateTimeDataFieldEh, TMTBlobDataFieldEh,
TMTBooleanDataFieldEh, TMTInterfaceDataFieldEh,
TMTVariantDataFieldEh, TMTRefObjectFieldEh.
TRecordsListEh
list of records.
TMemoryRecordEh
one record in list of record.
TRecordsViewEh
hold filtered list of records. Only those records that meet a TMemTableEh.Filter
conditions are hold in RecordsView.
Hold only records that TMemTableEh.Filter.
TMemoryTreeListEh
hold a tree-type list of TMemRecViewEh objects with references to record.

Storing records in tree mode (TreeView).


In tree mode the TMemTableEh create node objects (TMemRecViewEh type) for each record in
the internal array. Node object have reference to parent record (Rec property) and has a list of
child nodes (NodeItems).
Adjusting TreeView mode is realized by subproperties of TMemTableEh.TreeList property.
TMemTableEh automatically adds new record in the tree, using field values defined by
TreeList.KeyFieldName and TreeList.RefParentFieldName properties. When new record is
appearances in MemTable, it tries to find Parent record in the list of existing records, it looks
throw records trying to find values of the field in KeyFieldName that is equal to the value of the
field defined by RefParentFieldName property in the new record. Furthermore, it checks, if this
record is a parent for other existing records in array. Building of tree can be speeding up, if you

create indexes for fields specified in TreeList.KeyFieldName and TreeList.RefParentFieldName


properties. However the maximum speed of building tree is possible to achieve if the records all
records will be appended in DataSet in valid sequence. In other words every record must be
added in DataSet in same order as it appears in the tree. In last case it is not recommended to
create indexes, it can only slow down building of tree. If records appear in DataSet in valid
order set FullBuildCheck to False. It will not check if the new record have child records in
DataSet.
Subproperties of TMemTableEh.TreeList property:
Active: Boolean
Defines that TreeView mode is active. In TreeView mode you can access
TMemTableEh properties: TreeNodeLevel, TreeNodeExpanded, TreeNodeHasChildren,
TreeNodeChildCount for current record.
KeyFieldName: String
Holds a name of the key field of record. Child record will refer to parental record
with the key determined by the KeyFieldName field.
RefParentFieldName: String
Holds a name of the field that contain reference value to a parent record.
DefaultNodeExpanded: Boolean
Defines a value of Expanded property for new elements of the tree.
DefaultNodeHasChildren: Boolean
Defines a value of HasChildren property for a new elements of the tree.
FullBuildCheck: Boolean
Defines if need check if there are Child records in array for new record. Setting this
property to False can speed up building of tree, but all child records must be added after
parent record.
Use next TMemTableEh properties to access state of the tree node for the current record of
DataSet:
RecView: TMemRecViewEh
a reference to the tree node of the tree, it is available only in tree mode.
TreeNodeLevel: Integer
Indicates the level of the node in the tree.
TreeNodeExpanded: Boolean
Specifies whether the tree node is expanded.
TreeNodeHasChildren: Boolean
Indicates whether a node has any children.
TreeNodeChildCount: Integer
An amount of Child elements.

In addition, you can access the properties and methods for working with wood elements by the
property itself TMemTableEh.RecView. The property has the following properties for wood:
property NodeExpanded: Boolean
Node tree disclosed
property NodeHasChildren: Boolean
Node has a Child nodes
property NodeHasVisibleChildren: Boolean
The node has visible nodes Child
property NodeIndex: Integer
Index node in the node list Parent
property NodeItems[const Index: Integer]: TMemRecViewEh
Access to Child nodes
property NodeLevel: Integer
Level node in the tree
property NodeOwner: TMemoryTreeListEh
Tree nodes owner.
property NodeParent: TMemRecViewEh
Parent node for this node.
property NodesCount: Integer
Number of Child nodes
property NodeVisible: Boolean
Property Value Visible. The node can be visible or not visible in the tree. MemTableEh
automatically sets the status of the node, depending on the status of the filtering
entries. For all the records that do not fall into the filter assembly NodeVisible property
is set to False.
property VisibleNodeIndex: Integer
The index of the node in the list of visible nodes Parent node
property VisibleNodeItems[const Index: Integer]: TMemRecViewEh
Access to visible Child nodes
property VisibleNodesCount: Integer
The number of visible nodes Child

Below is a sample code that shows how to copy the contents and structure of the text
representation MemTableEh.
procedure TForm1.Button4Click(Sender: TObject);

procedure WriteTreeNode(Node: TMemRecViewEh);


var
i: Integer;
CurSubNode: TMemRecViewEh;
begin
for i := 0 to Node.NodesCount-1 do
begin
CurSubNode := Node.NodeItems[i];
DBMemoEh1.Lines.Add(
StringOfChar(' ', CurSubNode.NodeLevel) +
VarToStr(CurSubNode.Rec.DataValues['NAME', dvvValueEh]) + ' - ' +
VarToStr(CurSubNode.Rec.DataValues['ID', dvvValueEh]));
WriteTreeNode(CurSubNode);
end;
end;
begin
WriteTreeNode(
MemTableEh1.RecordsView.MemoryTreeList.Root
);
end;

The following code shows how to get a list of the top-level branches of which the current
branch MemTableEh.
procedure TForm1.Button5Click(Sender: TObject);
var
RecView: TMemRecViewEh;
begin
RecView := MemTableEh1.RecView;
while RecView <> MemTableEh1.RecordsView.MemoryTreeList.Root do
begin
DBMemoEh1.Lines.Add(

StringOfChar(' ', RecView.NodeLevel) +


VarToStr(RecView.Rec.DataValues['NAME', dvvValueEh])
);
RecView := RecView.NodeParent;
end;
end;

Workig with TMemTableEh at design-time.


At design-time the double click on the component opens a window of component
controling - TMemTableFieldsEditor. It allows:
Create fields (TField components) for TMemTableEh.
Fill TMemTableEh datas.
Load data in TMemTableEh from other DataSet.
Create 'stand-alone array of datas.
Clean TMemTableEh.
Create new TDataDriver object for TMemTableEh basing on existing DataSet-source of
data. Herewith, designer will try to assign DataDriver properties founding on the type DataSetsource. For instance, if you choose to create DataDriver of TSQLDataDriver type and DataSetsource
will
have
a
TQuery
type,
the
designer
will
assign
TSQLDataDriver.SelectComand.CommandText property automatically from TQuery.SQL
property.

TDataDriverEh component.
TDataDriverEh is universal data provider for TMemTableEh and a handler of the changes
in TMemTableEh. TDataDriverEh is a simplest supplier of datas, it is a agent between
TMemTableEh and other DataSet, that can to work with the database. Although many DataSets
can be connected to DBGrid directly, avoiding TMemTableEh, ligament DBGridEh-DataSourceMemTableEh-DataDriverEh-DataSet is possible to use if you want to use advantages of
DBGridEh functioning in ligaments with MemTableEh such as ViewScroll mode, tree-type
viewing of data, using same data by the several MemTableEhs.
In the mode of the supplier, TDataDriverEh takes data from DataSet that assigned to
ProviderDataSet property, and copies them in TMemTableEh. Before getting first record,
MemTableEh requests structure of fields from TDataDriverEh and create internal array of
records. TDataDriverEh build structure of fields on basis of fields list of ProviderDataSet. As
required, TDataDriverEh takes values of the current record, writes their to a new record of
TMemTableEh and goes over to the next record in ProviderDataSet.
Furthermore, TDataDriverEh can refresh values of the existing MemTable record from
ProviderDataSet (TMemTableEh.RefreshRecord method). TDataDriverEh find record in

ProviderDataSet using fields value from KeyFields property and reread values of record in
MemTable record. When TDataDriverEh is used as handler of change
(TMemTableEh.ApplyUpdates method), it takes a changed record from TMemTableEh, using
characteristic KeyFields, finds its position in ProviderDataSet, updates a record in
ProviderDataSet, queries it again from ProviderDataSet and returns a record back in
TMemTableEh.
Events of TDataDriverEh allows to control data which are transferred between
TDataDriverEh and TMemTableEh , as well as transfer and process changes from any/to other
types source of data.
TDataDriverEh have next events:
OnBuildDataStruct - write this event to change a structure of fields created when
TMemTableEh requests structure of fields. You can call DafaultBuildDataStruct method to build
a structure by default.
OnProduceDataReader - write this event to return dataset-cursor to read data. You can call
DefaultProduceDataReader method to define dataset-cursor by default. By default datasetcursor will be a ProviderDataSet.
OnReadRecord - write this event to assign values of record of new record that delivered to
TMemTableEh, or indicate that no more data. You can call DefaultReadRecord method to assign
values by default. By default values of record will be assigned from dataset-cursor. If Eof
function of dataset-cursor is True then TDataDriverEh indicate that no more data.
OnAssignFieldValue - write this event to assign a value of each field of new record that is
delivered to TMemTableEh, or when record is refreshing. Use DataValueVersion to determine
the mode of assigning: dvvValueEh when need to assign value for a new record,
dvvRefreshValue - when need to assign value for existing record. You can call
DefaultAssignFieldValue to assign a value of the field by default.
OnRefreshRecord - write this event to assign fresh value of fields at the refreshment of
record from the server. You an call DefaultRefreshRecord to assign fresh values by default.
OnUpdateRecord - write this event to process updated records in TMemTableEh. Use
MemRec.UpdateStatus property to determine the type of changes: Updating, Deleting or
Inserting. You can call DefaultUpdateRecord to process updated record by default. By default
DataDriver conducts changes in ProviderDataSet.
OnUpdateError - write this event to respond certain actions when error is arising in time of
processing updates.
Following reaction is possible when error is arising:
ueaBreakAbortEh

Break this and all following operations of changes, exception is not


raising.

ueaBreakRaiseEh

Break this and all following operations of changes, rollback


transactions, exception is raising.

ueaCountinueEh

Ignore an error, does not change a status of a record and continue a


performing the rest operations.

ueaRetryEh

Repeat an operation (You should undertake actions to prevent this


error on next time).

ueaUpdated CountinueSkip
Ignore an error, set record status to Unchanged, continue a
performing the rest operations.

You can call DefaultUpdateError to execute actions by default.

TSQLDataDriverEh component.
TSQLDataDriverEh is a universal DataDriver that can interact with server using SQL
commands. TSQLDataDriverEh have five objects of the TSQLCommandEh type: SelectCommand,
DeleteCommand, InsertCommand, UpdateCommand, GetrecCommand. Each object holds SQL
expressions and parameters to execute command to get table data, delete record, insert
record, update record and get one record. To execute commands TSQLDataDriverEh calls global
event - DefaultSQLDataDriverResolver.OnExecuteCommand. You should write this event to
execute SQL expressions on the server and, if need, return DataSet to read data. When
TSQLDataDriverEh is used as provider of data, it takes records from DataSet created in
DefaultSQLDataDriverResolver.OnExecuteCommand event and writes them in TMemTableEh.
On the measure of the requirement it takes given current record, writes them in TMemTableEh
and goes over to following record. When TSQLDataDriverEh is used as handler of changes, it
takes
a
changed
record
from
TMemTableEh,
and
call
DefaultSQLDataDriverResolver.OnExecuteCommand
event
sending
DeleteCommand,
InsertCommand or UpdateCommand as a parameter.
Using TSQLDataDriverEh it is possible change a type of the access to data. Suffice it to
rewrite global event - DefaultSQLDataDriverResolver.OnExecuteCommand.
TSQLDataDriverEh has a SpecParams property of TStrings type. You may use it to write the
special values, which you can use in the DefaultSQLDataDriverResolver.OnExecuteCommand
event. This event also is used by TServerSpecOperationsEh object when
DefaultSQLDataDriverResolver.ServerSpecOperations property is assigned. List of special values
depends of the type of TServerSpecOperationsEh object and values is filled similarly of
description in the "Characteristic TXXXDataDriverEh.SpecParams" section.
DefaultSQLDataDriverResolver.ServerSpecOperations property has a TServerSpecOperationsEh
type. This object is intended to process the special operations before or after ExecuteCommand
procedure is performed. TServerSpecOperationsEh is a base class for classes
TOracleSpecOperationsEh,
TMSSQLSpecOperationsEh,
TInterbaseSpecOperationsEh,
TInfromixSpecOperationsEh,
TDB2SpecOperationsEh,
TSybaseSpecOperationsEh
and
TMSAccessSpecOperationsEh. Each Of these objects can process a SpecParams property in
particular to get values of the autoincrement fields that is generated by the server. On the
name of the class it is possible to define a type of the server, for which class is intended.
For
full
functioning
of
TSQLDataDriverEh
it
is
necessary
to
write
DefaultSQLDataDriverResolver.OnExecuteCommand event to execute queries on the server and
assign DefaultSQLDataDriverResolver.ServerSpecOperations property by the object that
inherited from TServerSpecOperationsEh class. Assigning a ServerSpecOperations property
makes sense, if you execute operations of the insertion in tables that have autoincrement field
(or sequence objects).
The typical code to adjust working of TSQLDataDriverEh can be look as follows:
// Below code adjusts working of TSQLDataDriverEh components in the whole
Application to access
// InderBase server via BDE Engine
uses DataDriverEh, BDEDataDriverEh;
type

TMainForm = class(TMainForm)
Database1: TDatabase;
SQLDataDriverEh: TSQLDataDriverEh;

procedure TMainForm.FormCreate(Sender: TObject);


begin
DefaultSQLDataDriverResolver.OnExecuteCommand := OnExecuteSQLCommand;
DefaultSQLDataDriverResolver.ServerSpecOperations :=
TInterbaseSpecOperationsEh.Create;
end;
procedure TMainForm.FormDestroy(Sender: TObject);
begin
DefaultSQLDataDriverResolver.ServerSpecOperations.Free;
DefaultSQLDataDriverResolver.ServerSpecOperations := Nil;
end;
function TMainForm.OnExecuteSQLCommand(SQLDataDriver: TCustomSQLDataDriverEh;
Command: TCustomSQLCommandEh; var Cursor: TDataSet; var FreeOnEof,
Processed: Boolean): Integer;
begin
Result := DefaultExecuteBDECommandEh(SQLDataDriver, Command,
Cursor, FreeOnEof, Processed, Database1.DatabaseName);
end;

TSQLDataDriverEh is a base class for TBDEDataDriverEh, TIBXDataDriverEh,


TDBXDataDriverEh and TADODataDriverEh. These objects overwrite ExecuteCommand
procedure and them can execute SQL expressions on the server and if need returns DataSet to
read data. When SQL commands is called, it creates DataSet with type of corresponding type of
the access to data. For TBDEDataDriverEh it is a TQuery, for TIBXDataDriverEh it is a TIBXQuery
and so on. Furthermore, TBDEDataDriverEh, TIBXDataDriverEh, TDBXDataDriverEh can define
TServerSpecOperationsEh object automatically. For TADODataDriverEh it is need to assign
DefaultSQLDataDriverResolver. ServerSpecOperations because ADO technology does not allow
to define a type of the server.
TSQLDataDriverEh have the next events:
OnExecuteCommand - write this event to execute SQL expression. You can call
TCustomSQLDataDriverEh.DefaultExecuteCommand method to process this event by default.
By
default
TCustomSQLDataDriverEh.
DefaultExecuteCommand
calls
DefaultSQLDataDriverResolver.ExecuteCommand
method,
which,
in
turn,
call
DefaultSQLDataDriverResolver.OnExecuteCommand event.
OnGetBackUpdatedValues - write this event to return updated values from server. You
can call TCustomSQLDataDriverEh.DefaultGetUpdatedServerValues method to process action
by
default.
TCustomSQLDataDriverEh.DefaultGetUpdatedServerValues
call
DefaultSQLDataDriverResolver.GetBackUpdatedValues. If it was not processed in
DefaultSQLDataDriverResolver
then
it
call
InternalGetServerSpecOperations.GetBackUpdatedValues.
InternalGetServerSpecOperations
returns object of TServerSpecOperationsEh type.

Property TXXXDataDriverEh.SpecParams.
Property SpecParams kept a list of parameters and values. TXXXDataDriverEh use them
when performing SQL expressions. Value of each parameter have to be wrote in the separate

line in the format PARAMETER_NAME =VALUE. Depending on the type of the server
(InterBase, Oracle, MSSQL, Informix) SpecParams can contain the following parameters.
On interaction with InterBase server:
GENERATOR - defines a name of the InterBase generator. DataDriver uses this
parameter to get current value of generator after the insertion of new record.
GENERATOR_FIELD - defines a name of the field, which will be assigned current value
of the generator after the insertion of new record.
AUTO_INCREMENT_FIELD - defines a name of the field, which DataDriver will set
AutoIncremet type. It is used on making a structure of the internal array of record.
On interaction with Oracle server:
SEQUENCE - will assign a name of the field Oracle sequences. DataDriver uses this
parameter for the reception of the current value of the sequence after the insertion of
new record.
SEQUENCE_FIELD - will assign a name of the field, which will be assigned current value
of the sequence after the insertion of new record.
AUTO_INCREMENT_FIELD - defines a name of the field, which DataDriver will set
AutoIncremet type. It is used on making a structure of the internal array of record.
On interaction with MSSQL server:
AUTO_INCREMENT_FIELD - defines a name of the field, which DataDriver will set
AutoIncremet type. It is used on making a structure of the internal array of record.
On interaction with Informix server:
AUTO_INCREMENT_FIELD - defines a name of the field, which DataDriver will set
AutoIncremet type. It is used on making a structure of the internal array of record.

Example of the list of parameters for InterBase server:


GENERATOR=EMP_NO_GEN
GENERATOR_FIELD=emp_no
AUTO_INCREMENT_FIELD=emp_no
SQL expression for the insertion of record must contain EMP_NO_GEN generator.
insert into
employee (EMP_NO, FIRST_NAME)
values
(:EMP_NO_GEN, :FIRST_NAME)

TSQLDataDriverEh or TXXXDataDriverEh, which one is best to use.


As TSQLDataDriverEh as one of the TBDEDataDriverEh, TIBXDataDriverEh,
TDBXDataDriverEh or TADODataDriverEh components (we will name them as
TXXXDataDriverEh) allow to work with database without big number of tunings.
For TXXXDataDriverEh it is sufficiently to set database object property (For
TBDEDataDriverEh it is a Database property of TDatabase type).
TSQLDataDriverEh does not have database object property. To force it works is sufficiently to
write DefaultSQLDataDriverResolver.OnExecuteCommand event once to execute queries on

server, and assign DefaultSQLDataDriverResolver.ServerSpecOperations property by the object


of TServerSpecOperationsEh type to process some specific server operations.
DefaultSQLDataDriverResolver is not visual object, so you have to assign an event and property
in the program, for example in the OnCreate event of your main form. It is possible to change
access Engine to database quickly when you use TSQLDataDriverEh. It is sufficiently rewrite
global event - DefaultSQLDataDriverResolver.OnExecuteCommand only.
TSQLDataDriverEh and TXXXDataDriverEh works very similar at design-time. When
TSQLDataDriverEh component editor is opening you can choose one of design-time types of the
database accesses that built-over BDE, ADO, IBX and DBX engines. It is not necessarily that the
access engine that you use at design-time will be same as you write in
DefaultSQLDataDriverResolver.OnExecuteCommand event.

Working with TSQLDataDriverEh and TXXXDataDriverEh at designtime.


Double click on TSQLDataDriverEh or TXXXDataDriverEh component opens a dialog editor of
TSQLDataDriverEh component. At a design-time TSQLDataDriverEh and TXXXDataDriverEh
always use design time copy of object that work with database (it is TDatabase object for DBE
engine). If where are not any object was created the system will offer to create a new object.
Type of dialog of creating DB Object depend of type of TXXXDataDriverEh. For
TSQLDataDriverEh it show dialog where you can choose a type of the access to server (Engine)
and service of data processing of server (DB Service). Type of the access defines a engine to
access the data and can be one of the following types: BDE, IBX, DBX or ADO. For ADO also
need to define "Service a data processing", class that can get a list of DB objects from server. If
object that work with database already has been create before then system will offer to choose
one of the existing.
Window of editing TSQLDataDriverEh have a next controls:
1. Tree list of DB objects. Tables, Views, Procedures, Functions etc. It depends of server
type.
2. Lower window of elements of the current object in the tree of objects.
3. Output grid of result of executing the Select expressions.
4. Page of Select expression (TSQLDataDriverEh.SelectSQL)
5. Pages expressions for Inserting, Updating, Deleting, Requesting one record.
6. Page to fill SpecParams property and parameters of dynamic SQL building.

Uisng Connection Provider.


TMemTableEh - TXXXDataDriverEh - TXXXConnectionProviderEh
New components TXXXConnectionProviderEh provide a single point of connection to the database.
TADOConnectionProviderEh for ADO, TDBXConnectionProviderEh for DBExpress etc. for each method of
data access component of your ConnectionProvider. ConnectionProvider he does not join, but has builtin component InlineConnection (for ADO is TADOConnection, for DBExpress TSQLConnection, etc.) and
additional properties, a reference to the standard data access component of the same type (for example
if you want to lay TADOConnection separately on form). In component TXXXConnectionProviderEh you
also specify the type of server data (MSAccess, SQLServer, Oracle, InterBase, etc.). Some
ConnectionProvider
automatically
determine
the
type
of
server
(for
example,

TIBXConnectionProviderEh this will always be the server 'InterBase'). The type of server components
defines additional parameters for the database server. For example, on the type of server component
TXXXDataDriverEh defines the operating
mode with auto increment fields. In
TXXXConnectionProviderEh can specify different connection objects at the Design-Time and Run-Time,
thereby dividing the ways you can connect to the database during development and in the period of the
program. The component also allows you to specify access TADOConnectionProviderEh path to
MSAccess database in Design-Time line relative file location. A relative path starts from the location of
the form file, which has a component TADOConnectionProviderEh.
For example:
ADOConnectionProviderEh1.InlineConnection.ConnectionString = 'Provider =
Microsoft.Jet.OLEDB.4.0;
Data Source =% PROJECT_PATH% \ ..\ Data \ DBTest.mdb;
Persist Security Info = False '
When you open the form in Design-Time component replaces the macro "% PROJECT_PATH%" to the
path where the dfm form file is. This allows you to move the project to different computer and at
different location without changing the ways of access to the database file.

Demo:

See Demo project using cords TMemTableEh-TADODataDriverEh-

TADOConnectionProviderEh in your library - <EhLib


Dir\Demos\DataDriver.ADO.SimpleDemo>

Demo:

See Demo project using cords TMemTableEh-TBDEDataDriverEh-

TBDEConnectionProviderEh in your library - <EhLib


Dir\Demos\DataDriver.BDE.SimpleDemo>

Demo:

See Demo project using cords TMemTableEh-TDBXDataDriverEh-

TDBXConnectionProviderEh in your library - <EhLib


Dir\Demos\DataDriver.DBX.SimpleDemo>

Demo:

See Demo project using cords TMemTableEh-TIBXDataDriverEh-

TIBXConnectionProviderEh in your library - <EhLib


Dir\Demos\DataDriver.IBX.SimpleDemo>

Macro variables in SQL expressions SQLDataDriverEh.XXXCommand.


SQL expression in SQLDataDriverEh commands (ADODataDriver, DBXDataDriver, ...) can contain Macro
variables. Before executing the SQL statement the Macro variables are replaced by the values assigned
to them and actual SQL statement is formed, which is transmitted for execution.
For example the expression select * from %table_name% contains a macro variable
"%table_name%". If this variable contains the value of "Country", a real expression that will be
transferred to the execution will be the next 'select * from Country'.
You can type in SQLDataDriverEh.SelectSQL, UpdateSQL, DeleteSQL, InsertDQL, GetrecSQL commands
any expression that may contain a combination of SQL statements and macro variables.

In the collection of the elements SQLDataDriverEh.MacroVars.Macros it is necessary to create macroelements and give them names according to the variables inscribed in the SQL command. At design-time
you can enter the values of macro variables, or leave them blank.
At run-time before the opening MemTableEh connected to SQLDataDriverEh you can set the value of
the macro variable:

ADODataDriverEh1.SelectSQL.Text := select * from %table_name%


ADODataDriverEh1.MacroVars.Macros['%table_name%'] := Country;
MemTableEh1.Open;

if Conditions
then ADODataDriverEh1.MacroVars.Macros['%table_name%'] := table1
else ADODataDriverEh1.MacroVars.Macros['%table_name%'] := table2;

Use SQLDataDriverEh.FinalSelectSQL, FinalUpdateSQL, FinalInsertDQL, FinalGetrecSQL properties to


access the actual SQL expression.

Demo:
library

See a Demo project of using macro variables in the folder of the


<EhLib Dir\Demos\DataDriver.Macros>

Special macro variables.


There are two special macro variables in SQLDataDriverEh. Their names are stored in the properties
SQLDataDriverEh.MacroVars.SpecMacros.FilterMacroName
SQLDataDriverEh.MacroVars.SpecMacros.SortOrderMacroName
First macro variable FilterMacroName is the name that will be used when the filter is in DBGridEh
when preferences contain the following values:

DBGridEh.STFilter.Local = False

DBGridEh SQLDataDriverEh connected to the scheme - DBGridEh.DataSource.MemTableEh.


SQLDataDriverEh.

SQLDataDriverEh.SpecMacrosUsages contains value smuUseFilterMacroEh.

If smuUseFilterMacroEh not exist in SQLDataDriverEh.SpecMacrosUsages, filtering through the change


SQL statements will be executed under the scheme described in EhLib users guide section - Sorting and
filtering data in DBGridEh.
Default FilterMacroName contain values '% Filter%'.
The formation of the variable FilterMacroName affect property values in SpecMacrosUsages:
SmuFilterAsWhereClauseEh value specifies that in the event of non-null value to filter the string
value of this macro variable will generate the following rule 'where Filter Expression'. In this
case SQLDataDriverEh.SelectSQL can be written as 'select from Country% Filter%'. If filtering is
coming from DBGridEh is empty (show all data) SQLDataDriverEh.FinalSelectSQL then made the
following expression 'select from Country' (explanatory variables% Filter% 'is an empty string). If

the expressions for filtering input from DBGridEh will not empty, the variable% Filter% 'has the
value' WHERE Filter Expression '.
SmuFilterWithANDPrecedingEh value specifies that in the event of non-null value to filter the
string value of this macro variable will generate the following rule 'AND Filter Expression'.
If smuFilterAsWhereClauseEh and smuFilterWithANDPrecedingEh SpecMacrosUsages absent in
the string value of the filter will be formed as is, without additional prior expression 'Filter
Expression'
Second macro variables SortOrderMacroName is the name that will be used when applying sorting
DBGridEh when preferences contain the following values:
DBGridEh.SortLocal = False
DBGridEh SQLDataDriverEh connected to the scheme - DBGridEh.DataSource.MemTableEh.
SQLDataDriverEh.
SQLDataDriverEh.SpecMacrosUsages contains value smuUseSortOrderMacroEh.
If smuUseSortOrderMacroEh not exist in SQLDataDriverEh.SpecMacrosUsages, sorting through change
SQL expression will be executed under the scheme described in EhLib users guide section - Sorting and
filtering data in DBGridEh.
Default FilterMacroName contain values '% Filter%'.
The formation of the variable SortOrderMacroName affect property values in SpecMacrosUsages:
SmuSortOrderAsOrderByClauseEh value specifies that in the event of non-null value to sort the
string value of this macro variable will generate the following rule 'ORDER BY 3, 7, ...'. In this
case SQLDataDriverEh.SelectSQL can be written as 'select from Country% SortOrder%'.
SmuSortOrderWithCommaPrecedingEh value specifies that in the event of non-null value to sort
the string value of this macro variable will generate the following rule ', 3, 7 ...'. In this case
SQLDataDriverEh.SelectSQL can be written as 'select from Country order by 5% SortOrder%'.
If smuSortOrderAsOrderByClauseEh smuSortOrderAsOrderByClauseEh and not in
SpecMacrosUsages, the string value of the filter will be created as is, without additional prior
expressions '3, 7, ... '. In the absence of information on the sorting will be set empty string value.

Demo:

See a Demo project of using macro variables in the folder of the

library

<EhLib Dir\Demos\DataDriver.SpecMacros>

Properties of the TADOConnectionProviderEh Component.


Property Name
Connection
InlineConnection
InlineConnection.

Type
Description
TADOConnection
Link to an external component ADOConnection.
TADOInlineConnectionEh Built-in component ADOConnection.
Boolean

Connected
InlineConnection.

WideString

ConnectionString
InlineConnection.

Boolean

Use InlineConnection in Design-Time.

UseAtDesignTime
InlineConnection.

Boolean

Use InlineConnection in Run-Time.

UseAtRunTime
InlineConnection.

TxactAttributes

Attributes
InlineConnection.

Integer

CommandTimeout
InlineConnection.

Integer

ConnectionTimeout
InlineConnection.

TConnectOption

ConnectOptions
InlineConnection.

TCursorLocation

CursorLocation
InlineConnection.

WideString

DefaultDatabase
InlineConnection.

TIsolationLevel

IsolationLevel
InlineConnection.

Boolean

KeepConnection
InlineConnection.

Boolean

InlineConnection.

LoginPrompt
InlineConnection.

TConnectMode

Mode
InlineConnection.

WideString

Provider
Path

string

ServerType

string

ReadOnly property contains the path to the


project in Design-Time. Is used when specifying
paths ConnectionString with the macro%
PROJECT_PATH%.
Name of the server type.
In the current version

Events of TADOConnectionProviderEh component.


Property Name
OnExecuteCommand
OnGetBackUpdatedValues
OnGetServerSpecOperations
OnUpdateRecord
InlineConnectionBeforeConnect
InlineConnectionAfterConnect

Type
Description
TResolverExecuteCommandEhEvent
TResolverGetBackUpdatedValuesEhEvent
TResolverGetServerSpecOperationsEh
TResolverUpdateRecordEhEvent
TNotifyEvent
TNotifyEvent

Components for consolidated data analysis


The EhLib library contains a set of components for consolidated data analysis.
For formation and working with consolidated data the following components of library are
used:
TPivotDataSourceEh component for loading and storing of consolidated data.
TPivotGridEh
component a control element for consolidated data displaying
TPivotGridToolBoxEh component a control element for setup of data and sections
structure stored in PivotDataSource component
Description of components of data analysis.
To create the elementary form for operation with components of consolidated data analysis do
the following steps:
1. Place on the form and set up DataSet which will be the supplier of data for
PivotDataSource.
2. Place on the form PivotDataSource.
3. Set PivotDataSource.DataSet property to be pointed on DataSet which is set up on step
1.
4. Place on the form PivotGridEh and PivotGridToolBoxEh.
5. Set PivotGridEh.PivotDataSource and PivotGridToolBoxEh.PivotDataSource properties to
be pointed on PivotDataSource which is set up on step 2.
Next steps are usually performed in Run-Time:
6. Creation of structure of the internal buffer table in PivotDataSource based on DataSet
fields or from scratch.
PivotDataSourceEh1.PivotFields.RebuildPivotFields;
7. Loading data from DataSet to PivotDataSource.
PivotDataSourceEh1.CreateAndFillSourceTable;
8. Setup sections and fields with consolidated data.
PivotDataSourceEh1.ColumnFields.Add('SaleDate.Year');
PivotDataSourceEh1.RowFields.Add('ShipVIA');
with PivotDataSourceEh1.ValueFieldDefs.Add do
begin
PivotFieldName := 'AmountPiad';
SumFunction := svtSumEh;
end;

Usually settings of sections are stored in the configuration file or database.


9. Formation of the consolidated report.
PivotDataSourceEh1.BuildPivotData;

Demo project of using components of the consolidated analysis of the data, see the library
archive: <EhLib archive>\Demos\PivotGridEh.SimpleDemo\PivotGridEh.SimpleDemo.dpr

Indicator data generation TPivotGridEh with the possibility of interrupting


the process
In TPivotGridEh during long formation of data
indicator (ProgressBar) of data generation is
displayed with the possibility of interruption
by pressing ESC key.
Method of forming data remains the same. To
generate
the
data
TPivotDataSourceEh.BuildPivotData method is used;
To control the displaying of the progress bar use the following properties of TPivotGridEh class:
ShowDataBuildingProgress: Boolean
Defines necessity of displaying indicator during data formation.
DataBuildingProgressDelay: Integer
Defines interval (in milliseconds) after which it is necessary to display indicator. If
data formation time less than specified interval then indicator will not be shown.

Components for planning and visual interactive event


management
The library contains a set of components for planning and visual interactive control events tied
to a specific period of time.
Component TPlannerDataSourceEh
TPlannerDataSourceEh component is used for storing TPlannerDataItemEh objectsevents.
Component TPlannerControlEh.
The visual componentcontainer
TPlannerControlEh
contains
a
set
of
PlannerView
visual
components.
Each of the PlannerView
components
displays
period of time and events
on it in a specific format.
On screenshot on the left
side TPlannerControlEh
component
contains
PlannerView
of
TPlannerDayViewEh type,
which displays a set of
events for one day.
In current version PlannerView elements can have one of the following types:
TPlannerDayViewEh
Displays an interval of time one day long and
events fall into it.

TPlannerWeekViewEh

Displays an interval of time one week long


and events fall into it.

TPlannerMonthViewEh

Displays an interval of time one month long


and events fall into it.

TPlannerVertDayslineViewEh

Displays an interval of time of different length


in vertical orientation with cells length of one
day.

TPlannerVertHourslineViewEh

Displays an interval of time of different length


in vertical orientation with cells length of one
hour.

TPlannerHorzHourslineViewEh

Displays an interval of time of different length


in horizontal orientation with cells length of
one day.

TPlannerHorzDayslineViewEh

Displays an interval of time of different length


in horizontal orientation with cells length of
one hour.

TPlannerControlEh component contains PlannerView components by analogy as a


PageControl standard component contains a set of TabSheets bookmarks.
Component TPlannerCalendarPickerEh
The visual component- calendar is designed to navigate
through days of a month.
On select a date in the calendar, the component
automatically sets the current day in tied
TPlannerControlEh component. For bundles of two
components
using
the
property
type
TPlannerCalendarPickerEh.PlannerControl
TPlannerControlEh.
For
linking
two
components
use
TPlannerCalendarPickerEh.PlannerControl property of TPlannerControlEh type.
On changing the current period directly in TPlannerControlEh or through
TPlannerCalendarPickerEh, component PlannerControl each time refers to the
TPlannerDataSourceEh tied component to get a list of TPlannerDataItemEh objectsevents for the required period.
Communication of PlannerControl and PlannerDataSource components performs
through TPlannerControlEh.TimePlanSource property of TPlannerDataSourceEh type.
Loading elements-events from DB or another storage.
Data about events is loaded into TPlannerDataSourceEh in the program code similar to
the following example:
PlanItem := PlannerDataSourceEh1.NewItem();
PlanItem.ItemID := MyDataSet1['Id'];
PlanItem.StartTime := MyDataSet1['StartTime'];
...
PlannerDataSource.FetchTimePlanItem(PlanItem);

Another way of data loading through binding of DataSet and fields of DataSet.
For binding setup use sub-properties of TPlannerDataSourceEh.ItemSourceParams
property.
Set the TPlannerDataSourceEh.ItemSourceParams.DataSet property to DataSet which
should be used to load data from.
Fill
TPlannerDataSourceEh.ItemSourceParams.FieldsMap
collection
with
TItemSourceFieldsMapItemEh elements to set link between DataSet field and property
of TPlannerDataItemEh element-event.

Uploading of changed elements to DB.


On any change of an element of PlannerDataItem event TPlannerDataSourceEh
component calls OnApplyUpdateToDataStorage event where it is necessary to write a
code for transfering properties of changed PlannerDataItem element to the database.
The event code can look as follows:
TimePlanSource: TPlannerDataSourceEh; PlanItem: TPlannerDataItemEh;
UpdateStatus: TUpdateStatus);
begin
if UpdateStatus = usModified then
begin
if mtPlannerData.Locate('Id', PlanItem.ItemID, []) then
begin
mtPlannerData.Edit;
mtPlannerData['StartTime'] := PlanItem.StartTime;
mtPlannerData['EndTime'] := PlanItem.EndTime;
mtPlannerData['Title'] := PlanItem.Title;
mtPlannerData['Body'] := PlanItem.Body;
mtPlannerData['AllDay'] := PlanItem.AllDay;
mtPlannerData['ResourceID'] := PlanItem.ResourceID;
mtPlannerData.Post;
end else
raise Exception.Create('Can'' locate record with
"Id"='+VarToStrDef(PlanItem.ItemID, '<Null>'));

In this example changed data in PlanItem event is transferred to the mtPlannerData


record of the DataSet.
Resources and events.
TPlannerDataSourceEh component also contains the concept of resources.
Each event can be linked to one of the resources from the collection of resources.
If the list of events is the list of tasks which should be performed by a person, then list of
resources is list of people one of which can be assigned to perform a specific task.
To access the elements of the collection use a sub-properties of
TPlannerDataSourceEh.Resources property.
Typically, a collection of resources is filled before completing the collection of PlanItem
events.
Filling the collection of resources is done in the code like this
with TimePlanSourceEh1.Resources.Add do
begin
Name := mtResource.FieldByName('Name').AsString;
ResourceID := i;
end;

See demo project in folder <EhLib Archive>/DEMOS/PlannerEh.MainDemo

Components for uploading DataSet to a text file and load a


text file
The library contains components for uploading data from a DataSet to a text file for later
downloading from it.
Data can be uploaded to a file in a format with separators of values or in a format of the fixed
length for each field.
When importing and exporting data it is possible to set additional settings of the data format
such as: Format of dates, date separator, time format, time separator, decimal separator, etc.
Component TDataSetTextExporterEh
In Design-Time call the following method to configure components properties which will define
format of uploaded in Run-Time data
procedure TDataSetTextExporterEh.ExportToFile(AFileName: String; AppendToFile:
Boolean = False);

or
procedure TDataSetTextExporterEh.ExportToStream(AStream: TStream);

The first method stores data in a file, the second one stores data in a stream. If set
AppendToFile to True, then data will be append to the file but not will be rewritten.
Main properties of TDataSetTextExporterEh component
Property Name

Property Type

Description

DataSet

TDataSet

DataSet which data will be used as


source of export.

Encoding

TExportImportEncodingEh

Encoding in which data will be unloaded


TExportImportEncodingEh type has the
following values:
eieAutoEh - upload data in format
specified by the global variable
DefaultExportEncoding.
eieUTF7Eh - upload data in format
eieUTF7Eh.
Other values: eieUTF8Eh, eieUnicodeEh,
eieBigEndianUnicodeEh, eieANSIEh,
eieASCIIEh.

ValueSeparationStyle

TValueSeparationStyleEh

Style of division of values during


exporting data
vssFixedPositionAndSizeEh fields have
fixed lengths specified through
TFieldsMapItemEh.FileFieldLen
vssDelimiterSeparatedEh fields are
separated by a separator specified by

ValueDelimiter property.
ValueDelimiter

Char

Separator of field values in an output


data stream.

QuoteChar

Char

Sign of quotes in which recorded values


will enclosed.

IsExportFieldNames

Boolean

Property specifies necessity to record


names of fields in the first row of the
export file.

ExportValueAsDisplayText

Boolean

Property specifies style of transferring


fields values to their text presentation.
In case of ExportValueAsDisplayText =
True, Field.DisplayText property will be
used to get data from Field, otherwise
will be used Field.Value property.

ValueExceedsSizeLimitAction

TValueExceedsSizeLimitActi
onEh

Action to be done if length of fields


value exceeds length specified in
TFieldsMapItemEh.FileFieldLen.

ExportRecordsCount

Integer

Amount of unloaded records. -1 value


specifies necessity to unload all records
from DataSet.

ExportFormats

TExportImportFormatsEh

Sets formats and separators for the data


type of Date, Time and Number.

FieldsMap

TFieldsMapCollectionEh

Specifies a collection of
TfieldsMapCollectionEh elements. Each
element of the collection defines the
parameters of a field in the export file. If
the FieldsMap collection is empty, then
all fields of DataSet will be exported.

Main events of TdataSetTextExporterEh component


Property Name
Property Type

Description

OnStartExport

TNotifyEvent

Called before start of data export

OnFinishExport

TNotifyEvent

Called after end of data export

OnExportTitle

TDataSetTextExporterExportLineEven
tEh

Called when exporting the column


headings

OnExportRecord

TDataSetTextExporterExportLineEven
tEh

Called when exporting a single DataSets


record. StreamWriter parameter of
TStreamWriter type is passed to handler
to use to record additional information
to stream, use completely own
algorithm of data exporting or call the
default method
Exporter.DefaultExportRecord
(StreamWriter); for data exporting.

OnTruncateTitleField

TTruncateTitleFieldEventEh

Called when it is needed to cut off the

name of a header field


OnTruncateDataField

TTruncateDataFieldEventEh

Called when it is needed to trim the


value field

OnGetFieldSize

TGetFieldSizeEventEh

Called to get the size of the field

OnFormatExportValue

TFormatTextExportValueEventEh

Called when exporting a single field


value. In the event handler it can be
written down the exported value in the
Value parameter. If default handler of
value formatting is overriden then set
Processed parameter to True as well.

Component TDataSetTextImporterEh
Configure components properties in Design-Time.
Call the following method in Run-Time
procedure TDataSetTextImporterEh.ImportFromFile(AFileName: String);

or
procedure TDataSetTextImporterEh.ImportFromStream(AStream: TStream);

See demo project in folder <EhLib Archive>/DEMOS/DataSetImpExp

Hiding a component form in Design-Time


TCompoManEh component
TCompoManEh component is intended for use only in the Design-Time.
TCompoManEh can hide other components form during development, thereby enabling to see
the design of the form as close to the design mode Run-Time.

The upper screenshot the form is whown at Desig-Time. All components, except the
TCompoManEh, are hidden by a component editor CompoManEh1. The right side of the
screenshot you can see a window with a list of hidden components. The window opens when
you double-click on CompoManEh1. The window contains all the components form TForm2.
Right-click on the component from the list of Popup Menu Editor opens the selected
components.

Feedbacks and bug reports


Please inform us of all errors found in the library. In preparing the data, try to specify how much
information about the error. To verify your information we need to model a similar situation on
our computers.
Include information about the operating system and Service Pack's, version of Delphi (with
Build) and version EhLib.
Also, if possible, check the error occurred on other computers, operating systems, other
versions of Delphi, other versions EhLib.
The most effective results will be achieved, if you send the source code of the project, which
demonstrates the error. Demo project can include standard DataSet'y (not the third party) and
use tables or files DBDEMOS MSAccess, or you can copy your data from your dataset to
TClientDataSet or MemTableEh.

Potrebbero piacerti anche