Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Developers guide
EhLib Team
Edition: 2.01
(Changes compared to
revision 2.00 is highlighted in
red)
Contents
Introduction ............................................................................................................... 5
Installation ............................................................................................................... 10
Unpacking archive ..................................................................................................................... 10
Installing packages. ................................................................................................................... 10
Installing help files. ................................................................................................................... 12
Components for planning and visual interactive event management ................... 133
Printing of TPlannerControlEh ................................................................................................ 135
Show Hint Winow for planner Items. ...................................................................................... 135
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.
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 Run-Time.
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 Design-Time and RunTime. Contains built TIBDatabase component.
TBDEConnectionProviderEh component
Provides the interface between the component TBDEDataDriver and TDatabase in Design-Time and RunTime. 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.
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
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.
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 are set with the TColumnEh.Title.SortMarker property.
The column data type Combobox Editor is a column in which the data
opened for editing text editor with the ability to select data from the
down list. In the right part of column the editor shows the special
button DropDownEditButton. When clicked, it displays a drop-down
is
drop-
edit
within
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.
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 sub-properties 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
LookupDisplayFieldName String
LookupKeyFieldNames
String
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.
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 SpecRow columns and components DBGridEh DBLookupComboBoxEh.
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."
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.
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.
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
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
cursor
of "index
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.
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.
You can also directly call the DataSet.Post to finish editing the recording immediately after recording the
data in the field.
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.
using
the
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.
Property Type
Description
DisplayFormat
String
EndEllipsis
Boolean
Layout
TTextLayout
Alignment
TAlignment
WordWrap
Boolean
EditMask
String
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
Column: TColumnEh
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.
The background color that will be used to paint a cell. You can
change this parameter to specify a new color.
State: TGridDrawState
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
EditMode: Boolean
Params: TColCellParamsEh
Params.Alignment: TAlignment
Text alignment.
Params.Background: TColor
background color
Params.BlankCell: Boolean
Params.SuppressActiveCellColor:
Boolean
Params.CheckboxState:TCheckBoxState
Params.Col: Longint
Params.CellRect: TRect
Params.Font: TFont
Params.ImageIndex: Integer
Params.ReadOnly: Boolean
Params.Row: Longint
Params.State: TGridDrawState
Cell status
Params.Text: String
Params.TextEditing: Boolean
Params.DrawCellByThemes:Boolean
Params.TextIsLink: Boolean
Params.ImageIsLink: Boolean
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.
Setting color dividing lines, the presence / absence of lines in various areas Grid.
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.
glcsClassicEh - The classic filling.Black lines for
fixed areas. Gray lines for the data area.
VertEmptySpaceStyle TDrawEmpty
SpaceStyle
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.
TDBGridEh.TitleParams.VertLineColor: TColor
TDBGridEh.TitleParams.VertLines: Boolean
TDBGridEh.TitleParams.HorzLineColor: TColor
TDBGridEh.TitleParams.HorzLines: Boolean
TDBGridEh.IndicatorParams.HorzLineColor: TColor
TDBGridEh.IndicatorParams.HorzLines: Boolean
TDBGridEh.IndicatorParams.VertLineColor: TColor
TDBGridEh.IndicatorParams.VertLines: Boolean
TDBGridEh.FooterParams.HorzLineColor: TColor
TDBGridEh.FooterParams.HorzLines: Boolean
TDBGridEh.FooterParams.VertLineColor: TColor
TDBGridEh.FooterParams.VertLines: Boolean
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 run-time 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
run-time 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
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.
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 tree-type
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
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
Font and
the text.
group.
Dataset
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.
GroupPanelVisible
GroupFootersEh
TGridDataGroup
FootersDefValuesEh
Boolean
ParentColor
ParentFont
DefaultStateExpanded
Boolean
Boolean
Boolean
FootersDefValues
GroupRowDefValues
TGridDataGroup
RowDefValuesEh
ShiftFolldataGroupRow Boolean
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.
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
Grid
Column
GroupFooter
FooterColumnItem
var AValue
Node
var Processed
OnDataGroupFooterFinalizeValue
Grid
Column
GroupFooter
FooterColumnItem
var AValue
var Processed
Description
Called
after
all
calls
OnDataGroup
FooterAggregateValue. In the event it is
necessary to perform the final calculation of
aggregate functions.
TCustomDBGridEh
TColumnEh
TGridDataGroup
FooterEh
TGridDataGroup
FooterColumnItemEh
Variant
Boolean
OnDataGroupFooterToDisplayText
Grid
Column
TCustomDBGridEh
TColumnEh
GroupFooter
FooterColumnItem
TGridDataGroupFooterEh
TGridDataGroup
FooterColumnItemEh
var AValue
var DisplayValue
var Processed
Variant
string
Boolean
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 non-standard
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.
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,
HorzMargin
VertMargin
ExcludeTitle
ExcludeIndicator
ExcludeFooter
Integer
Integer
Boolean
Boolean
Boolean
ipCenterRightEh,
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.
set
At
Run-
search
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.
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.
There is ellipses button "..." in the TDBGridEh SearchPanel. Click on the button opens a drop down menu
where you can choose the following search options in the grid:
- Search area: The current column or the entire grid.
- Search with or without text case.
- Search complete words or parts of words.
If the found text is hidden behind the border of the cell, the number of hidden found matches is displayed
in a yellow box at the top right side of the cell .
To configure the settings panel, search and filter properties using sub-properties DBGridEh.SearchPanel.
DBGridEh.SearchPanel: TDBGridSearchPanelEh
Sub-properties properties TDBGridEh.Border:
Enabled: Boolean
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
Boolean
Specifies that filter is available in the search panel. If FilterOnTyping = False, then the search will only be
available by code.
OptionsPopupMenuItems: TDBGridSearchPanelOptionsMenuItemsEh
Specify a list of elements of the drop-down menu that appears on click of Search Options ("...") button in
SearchPanel.
TDBGridSearchPanelOptionsMenuItemsEh type may comprise the following meanings
gsmuSearchScopesEh Search Area.
gsmuCaseSensitiveEh Search in case-sensitive mode.
See the example of using events to write an advanced search through the Search Panel in the Folder:
DEMOS\DBGridEh.SearchPanel
section Demo3.
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
Visible
Boolean
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
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
TDBGridEhScrollBarPanel
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.
Property Type
Description
Visible
Boolean
NavigatorButtons
TNavButtonSetEh
VisibleItems
TGridSBItemsEh
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
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.
Style
TBorderStyle
end;
Demo:
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.
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.
(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:
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;
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.
Property Type
TColor
TFont
ParentFont
Boolean
Description
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
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
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';
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
smstClassicEh
smst3DFrameEh
smstFrameEh
smstSolidEh
smstThemeDefinedEh
Event to customize and draw title cells including SupperTitle in MuliTitile mode.
There are events in DBGridEh component to customize and render the header of the grid columns. These events
convenient to use for the top-level headers in MultiTitle mode because to TDBGridEh have no separate static objects
to configure the top-level headers.
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
Property Name
Color
FillStyle
Font
Property Type
TColor
TGridCellFillStyleEh
TFont
ParentFont
Boolean
RowHeight
RowLines
Integer
Integer
HorzLineColor
HorzLines
VertLineColor
VertLines
TColor
Boolean
TColor
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
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.
Property Type
Description
Active
Boolean
ExternalRecalc
Boolean
VirtualRecords
Boolean
Property Type
Description
Alignment
TAlignment
Color
TColor
DisplayFormat
String
EndEllipsis
Boolean
FieldName
String
Font
TFont
ToolTips
Boolean
String
ValueType
TFooterValueType
WordWrap
Boolean
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.
Property Type
Boolean
Local
Boolean
Location
TSTFilterLocationEh
Visible
Color
Font
Boolean
TColor
TFont
ParentFont
Boolean
HorzLineColor
RowHeight
RowLines
TColor
Integer
Integer
VertLineColor
TColor
FilterButtonDrawTime TDBGridFilter
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
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
ButtonDrawTimeEh
filter list.
ShowTree Lines
Boolean
tvgsClassicEh
tvgsThemedEh
tvgsExplorerThemedEh
Set this property to True to display the lines connecting the
elements of the tree.
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 = True): Variant;
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);
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.
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 Type
Description
DropdownMenu
TPopupMenu
ShowDropDownSign Boolean
TitleButton
TitleButton
UseGlobalMenu
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.
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.
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
Items[Index: Integer]
TUniBookmarkEh
CurrentRowSelected
Boolean
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
LeftCol
Longint
TopRow
TUniBookmarkEh
RightCol
Longint
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
Items[Index: Integer]
TColumnEh
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.
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
);
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.
dghMultiSortMarking
Allows set markers sorting multiple columns at once, to set markers sorting RunTime, 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 double-clicking 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.
Grid1: TDBGridEh;
end;
implementation
type
TDBGridEhCrack = class(TDBGridEh);
procedure TfrVertGrid.ToolButton1Click(Sender: TObject);
begin
TDBGridEhCrack(Grid1).ProptectedMethod;
end;
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.
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.
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
Rows
Options
Options
RowsDefValues
GridLineParams
GridLineParams
DataColParams
<There is no
analog>
TitleParams
LabelColParams
IndicatorParams
<There is no
analog>
Flat
Flat
DrawMemoText
DrawMemoText
SearchPanel
DBVertGridEh allows to search data in one record of DataSet via SearchPanel, as is done in TDBGridEh.
WholeWords: Boolean
Specifies that the search must be performed by the whole words when searching via Search Panel.
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.
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
values:
following
vgsoByFieldRowCaptionAscEh
vgsoByFieldRowCaptionDescEh
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.
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.
Printing of TDBVertGridEh
The DBVertGridEh components can be printed and previewed before printing.
See Demo project in the folder
DEMOS\PrintGrids
Use subproperties of PrintService property to configure and manage printing:
A set of properties and methods of PrintService property is identical for all components TDBVertGridEh,
TPivotGridEh and TPlannerControlEh.
The property is accessible at Design-Time.
TPrintColotSchemaEh
FitToPagesTall
Integer
FitToPagesWide
Integer
Orientation
TPrinterOrientation
PageFooter
TPageColontitleEh
PageHeader
TPageColontitleEh
PageMargins
TPageMarginsEh
Scale
Integer
ScalingMode
TScalingModeEh
TextAfterContent
TRichStringEh
TextBeforeContent
TRichStringEh
Page margins
property PrintService.PageMargins: TPageMarginsEh;
ColorSchema: TPrintColotSchemaEh;
FitToPagesTall: Integer;
FitToPagesWide: Integer;
Orientation: TPrinterOrientation;
Scale: Integer;
ScalingMode: TScalingModeEh;
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 is 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.
property AllowedOperations: TDBGridEhAllowedOperations
Set an allowed operations on a DataSet.
alopInsertEh Insert new recordings at any place of the grid (actually DataSet) is allowed.
alopUpdateEh Changing the values of an existing record is allowed.
alopDeleteEh Deleting records is allowed.
alopAppendEh Adding records to the end of the grid is allowed.
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;
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.
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 dataaware 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,
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.
DefaultAction
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.
DrawBackTime
It is allowed display the edit buttons in transparent background mode. In this mode, the edit button shows
only a foreground icon. See the second screenshort.
and Foreground part separately. For these buttons use alternative types - ebsAltDropDownEh and
ebsAltUpDownEh.
2. Transparent back drawing does not work when the button have ebsGlyphEh style and the picture is
in the Glyph property. To get around the restriction move a picture in TImageList component and
fill EditButton.Images property.
Use the following types of properties to set a transparent background for Buttons:
Types
TEditButtonDrawBackTimeEh = (edbtAlwaysEh, edbtNeverEh, edbtWhenHotEh);
edbtAlwaysEh Always draw the button background
edbtNeverEh Never draw the button background
edbtWhenHotEh Draw button background when a mouse cursor is over the button.
Properties
property TColumnEh.EditButton.DrawBackTime: TEditButtonDrawBackTimeEh
property TColumnEh.EditButtons[i].DrawBackTime: TEditButtonDrawBackTimeEh
Sets a drawing mode for button background in the column editor.
property TColumnEh.EditButton.DrawBackTimeStored: Boolean
property TColumnEh.EditButtons[i].DrawBackTimeStored: Boolean
Determines that the value of a DrawBackTime property is persistent and does not depend
on the value of other properties. If DrawBackTimeStored = False, the default value for the
DrawBackTime property is taken from
TDBGridEh.ColumnDefValues.EditButtonDrawBackTime property.
property TDBGridEh.STFilter.FilterButtonDrawBackTime:
TEditButtonDrawBackTimeEh
Sets a drawing mode for button background of STFilter buttons.
property TDBGridEh.STFilter.FilterButtonDrawBackTimeStored: Boolean
Determines that the value of a FilterButtonDrawBackTime property is persistent and does
not depend on the value of other properties. If DrawBackTimeStored = False, the default
value for the FilterButtonDrawBackTime property is taken from
TDBGridEh.ColumnDefValues.EditButtonDrawBackTime property.
property TDBGridEh.ColumnDefValues.EditButtonDrawBackTime:
TEditButtonDrawBackTimeEh
Sets a drawing mode for column editor buttons and STFilter buttons.
Similar properties are present in the classes of DBVertGridEh component
property TFieldRowEh.EditButton.DrawBackTime: TEditButtonDrawBackTimeEh
property TFieldRowEh.EditButtons[i].DrawBackTime:
TEditButtonDrawBackTimeEh
property TFieldRowEh.EditButton.DrawBackTimeStored: Boolean
property TFieldRowEh.EditButtons[i].DrawBackTimeStored: Boolean
property TDBVertGridEh.RowsDefValues.EditButtonDrawBackTime:
TEditButtonDrawBackTimeEh
Similar properties are present in the classes of TDBEditEh, TDBNumberEditEh, TDBDateTimeEditEh
components
property TDBEditEh.EditButtons[i].DrawBackTime: TEditButtonDrawBackTimeEh
property TDBEditEh.EditButtons[i].DrawBackTimeStored: Boolean
For an example of using properties for transparent background see the next demo project:
DEMOS\EditButton.DrawNoBack
OnClick, OnDown
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.
Property Type
Description
Action
TBasicAction
DefaultAction
Boolean
DropdownMenu
TPopupMenu
DropDownFormParams
TDropDownFormCallParamsEh
Enabled
Boolean
Glyph
TBitmap
Hint
String
Images
TEditButtonImagesEh
NumGlyphs
Integer
ShortCut
TShortCut
TEditButtonStyleEh
Visible
Boolean
Width
Integer
property
values,
choose
to only
For
a
The list of MRUList values can be formed automatically on the basis of a list of unique values in the
DataSet. To specify that the data should be taken from the DataSet set MRUList.ListSourceKind property to
lskDataSetFieldValuesEh.
Not all DataSets support access to the internal data structure for a list of unique values of a column.
In the current version of the library MRUList.ListSourceKind = lskDataSetFieldValuesEh mode works for
DataSet of TMemTableEh type. In one of the unit for your project it is necessary to add a EhLibMTE module
in the uses clause. This module contains a class that is able get unique values for a field.
If your DataSet supports the ability to get a list of unique values for a field, then you can write and register
your class inherited from TDatasetFeaturesEh. In the implementation of the class it must written a
FillFieldUniqueValues method. See the example of the implementation in the EhLibMTE.Pas file.
The TMRUListEh class contains the following properties:
property AutoAdd: Boolean
Automatically add new value to the list when the control lost input focus.
property Active: Boolean
MRUList is 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.
property ListSourceKind: TMRUListSourceKindEh
Defines a kind of source data for MRU DropDown list.
lskMRUListItemsEh source data for DropDown list will be taken from Items property.
lskDataSetFieldValuesEh source data for DropDown list will be taken from DataSet. For
DataSet a TDatasetFeaturesEh class must be registered with implementing of
FillFieldUniqueValues method to list of unique values for a dataset field.
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.
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.
TDBCheckBoxEh control
The component is designed to show checkbox sign with label text.
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 TDBCheckBoxEh.
In addition, the component contains the following additional features:
- WordWrap
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 value of the
Boolean
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.
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
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 dropdown 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
DropDownFormClassName: String
Align:
TDropDownAlign
edit control.
PassParams:
PassFieldNames:
String
AssignBackFieldNames:
String
FormWidth:
Integer
FormHeight:
Integer
SaveFormSize:
Boolean
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 designtime, 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.
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).
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.
To see a new possibilities of using Bookmarks in DBGridEh look at a Demo project in the folder
DEMOS\DBGridEh.MemTable.Bookmarks
Due to changes in the method of storing data in Bookmarks the SearchPanel of DBGridEh component no
longer supports searching within the selected records. Instead DBGridEh allows you to filter the data
through SearchPanel without losing the list of selected records in the grid. To make the selected records
not be cleared when navigating through DBGridEh when sorting set the dghClearSelection value in the
TDBGridEh.OptionsEh property.
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
We 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.
function BookmarkToRec(Bookmark: TUniBookmarkEh): TMemoryRecordEh;
Convert Bookmark object into a TMemoryRecordEh object.
function RecToBookmark(Rec: TMemoryRecordEh): TUniBookmarkEh;
Convert a MemoryRecord object into Bookmark object.
Type of TUniBookmarkEh class depends on the version of Delphi and can be TBookmark, array of Byte or
TBookmarkStr type.
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.
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.
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.
Demo:
See the Demo project of using macro variables in your library archive
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
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;
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-DataSource-MemTableEh-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 dataset-cursor 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.
Break this and all following operations of changes, exception is not raising.
ueaBreakRaiseEh
ueaCountinueEh
ueaRetryEh
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;
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, 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:
Demo:
Demo:
Demo:
if Conditions
then ADODataDriverEh1.MacroVars.Macros['%table_name%'] := table1
else ADODataDriverEh1.MacroVars.Macros['%table_name%'] := table2;
Demo:
See a Demo project of using macro variables in the folder of the library
<EhLib Dir\Demos\DataDriver.Macros>
DBGridEh.STFilter.Local = False
DBGridEh SQLDataDriverEh
SQLDataDriverEh.
connected
to
the
scheme
DBGridEh.DataSource.MemTableEh.
connected
to
the
scheme
DBGridEh.DataSource.MemTableEh.
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
Boolean
UseAtDesignTime
InlineConnection.
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 DesignTime. Is used when specifying paths ConnectionString with the
macro% PROJECT_PATH%.
Name of the server type.
In the current version
Type
Description
TResolverExecuteCommandEhEvent
TResolverGetBackUpdatedValuesEhEvent
TResolverGetServerSpecOperationsEh
TResolverUpdateRecordEhEvent
TNotifyEvent
TNotifyEvent
Place on the form and set up DataSet which will be the supplier of data for PivotDataSource.
Place on the form PivotDataSource.
Set PivotDataSource.DataSet property to be pointed on DataSet which is set up on step 1.
Place on the form PivotGridEh and PivotGridToolBoxEh.
Set PivotGridEh.PivotDataSource and PivotGridToolBoxEh.PivotDataSource properties to be pointed
on PivotDataSource which is set up on step 2.
Printing of TPivotGridEh
The TPivotGridEh components can be printed and previewed before printing.
Use subproperties of PrintService property to configure and manage printing.
Using of PrintService object is very similar to using the same property of TDBVertGridEh component. See
section Printing of TDBVertGridEh for details.
contains
visual
period of
specific
side
which
for one
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
TPlannerMonthViewEh
TPlannerVertDayslineViewEh
TPlannerVertHourslineViewEh
TPlannerHorzHourslineViewEh
TPlannerHorzDayslineViewEh
Component TPlannerCalendarPickerEh
The visual component- calendar is designed to navigate
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.
through
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;
Printing of TPlannerControlEh
The TPlannerControlEh components can be printed and previewed before printing.
Use subproperties of PrintService property to configure and manage printing.
Using of PrintService object is very similar to using the same property of TDBVertGridEh component. See
section Printing of TDBVertGridEh for details.
Show Hint Winow for planner Items.
There are event in the PlannerView to set data for hint window (Hints) that appear when mouse you hover
over the event item area.
OnSpanItemHintShow: TPlannerViewSpanItemHintShowEventEh
Write the event handler to change text, font or background color.
The hint window is appeared when a mouse moves and hold over the event area (TPlannerDataItemEh).
In the below example the OnSpanItemHintShow handler adds a new line with text 'NewLine' and sets the
hint font in bold style.
procedure TfrFrameOne.PlannerDayViewEh1SpanItemHintShow(
PlannerControl: TPlannerControlEh; PlannerView: TCustomPlannerViewEh;
CursorPos: TPoint; SpanRect: TRect; InSpanCursorPos: TPoint;
SpanItem: TTimeSpanDisplayItemEh; Params: TPlannerViewSpanHintParamsEh;
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
Encoding
TExportImportEncodingEh
ValueSeparationStyle
TValueSeparationStyleEh
ValueDelimiter
Char
QuoteChar
Char
IsExportFieldNames
Boolean
ExportValueAsDisplayText
Boolean
ValueExceedsSizeLimitAction
TValueExceedsSizeLimitActi
onEh
ExportRecordsCount
Integer
ExportFormats
TExportImportFormatsEh
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.
Description
OnStartExport
TNotifyEvent
OnFinishExport
TNotifyEvent
OnExportTitle
TDataSetTextExporterExportLineEven
tEh
OnExportRecord
TDataSetTextExporterExportLineEven
tEh
OnTruncateTitleField
TTruncateTitleFieldEventEh
OnTruncateDataField
TTruncateDataFieldEventEh
OnGetFieldSize
TGetFieldSizeEventEh
OnFormatExportValue
TFormatTextExportValueEventEh
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);
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.