What's new in EhLib.VCL 11.0
What's new in EhLib.VCL 11.0
Visual elements for complex formatting in grid cells (LaControls)
Added a mechanism for creating visual cells with complex formatting in TDBGridEh.
In grid cells, this formatting looks like RichText or HTML text.
At the same time, the formatting is not based on either the Rtf format or the HTML markup.
Formatting is based on internal classes that describe the layout of the elements inside the cell.
For formatting, special Layout Controls are used (Location elements, LaControls)
Here are examples of visual representations that can be created using LaControls elements.


For examples of using LaControls elements, see the Demo project<EhLib Archive>\Demos\LaObjects.MainDemo.
Creating a LaControls Element Tree Template.
In order for a grid cell to start rendering its content through LaControls elements, you need to create a placement description template and assign it to the TColumnEh.LaControlTemplate property. The grid will use a template to render the contents of the cell for each grid entry.
The template may contain references to DataSet fields. To do this, use the element's FieldName property. When rendered, the element will substitute the field value for each record in the DataSet.
In the current implementation, the library supports the creation of a tree of elements only in the program code. Working with elements in design-time is not supported.
Below is a simple example of creating an element tree:
constructor TfrOneFishFacts.Create(AOwner: TComponent);
var
ALaControl: TLaObjectEh;
begin
inherited Create(AOwner);
with TLaTextBlockEh.Create(Self) do
begin
FieldName := 'Species_Name';
Margins.SetBounds(10, 5, 5, 2);
ALaControl := RefSelf;
end;
DBGridEh1.Columns[0].LaControlTemplate := ALaControl;
end;The result will look like this:
In this example, we've created one LaControl of type TLaTextBlock , set padding from the edge of the cell, and specified that the LaControl should output values from the 'Species_Name' field. Then we use this LaControl as a template for the DBGridEh1.Columns[0] column.
This example does not contain complex formatting. We could implement this formatting without LaControls. But for the first time this is enough. In any case, we can already set the margins from the edges of the cell through the Margins property.
Panels
Panels allow you to group several elements into a group and arrange them on the screen according to certain rules.
In the current implementation, the library contains three types of panels:
TLaContentPanelEh- Simple panel container. Arranges multiple elements in the same area without a special layout algorithm.TLaStackPanelEh- Container stack panel. Arranges the element sequentially one after the other from left-to-right or top-to-bottom.TLaGridPanelEh- GridPanel container. Arranges elements in panel cells withcolumnsandrows.
Consider the use case of the TLaStackPanelEh element.
// Variant 2. Simple TLaStackPanelEh
constructor TfrOneFishFacts.Create(AOwner: TComponent);
var
ALaControl: TLaObjectEh;
begin
inherited Create(AOwner);
with TLaStackPanelEh.Create(Self) do
begin
Orientation := TLaOrientation.Vertical;
with TLaTextBlockEh.CreateWith(Self, RefSelf) do
begin
FieldName := 'Species_Name';
Margins.SetBounds(10, 5, 5, 2);
end;
with TLaTextBlockEh.CreateWith(Self, RefSelf) do
begin
FieldName := 'Category';
Margins.SetBounds(10, 5, 5, 2);
end;
with TLaTextBlockEh.CreateWith(Self, RefSelf) do
begin
Text := 'Static Text';
Font.Style := [fsBold];
Margins.SetBounds(10, 5, 5, 2);
end;
ALaControl := RefSelf;
end;
DBGridEh1.Columns[0].LaControlTemplate := ALaControl;
end;The result will look like this:
Here, the with statement and the special CreateWith constructor are used to add nested elements.
The table below lists the available elements and panels of the library:
| Element | Unit | Description |
|---|---|---|
| TLaObjectEh | LaObjectsEh | Base element for all placement elements. |
| TLaControlEh | LaControlsEh | Placement element with font, padding and border rendering settings. |
| TLaTextBlockEh | LaControlsEh | Placement element to display plain text. |
| TLaImageEh | LaControlsEh | Placement element for displaying pictures. |
| TLaFlowRichBlockEh | LaFlowRichBlocksEh | Placement element for text with the ability to set individual formatting for sections of text. |
| TLaGridPanelEh | LaGridPanelsEh | Grid container. Arranges elements in panel cells with columns and rows. |
| TLaContentPanelEh | LaPanelsEh | The container is a simple panel. Arranges multiple elements in the same area without a special layout algorithm. |
| TLaStackPanelEh | LaPanelsEh | Container-stack panel. Arranges the element sequentially one after the other from left-to-right or top-to-bottom. |
| TLaHintWindowEh | LaHintWindows | Window for displaying hints with the ability to format content through LaControls. |
| LaObjectTreeViewForms | Window for tree view of LaControls location and property of each element at Run-time. Used to test the display of a complex set of elements. |
Auto-highlighting links in a text cell DBGridEh
The TColumnEh.HighlightHyperLinks Boolean property has been added to the DBGridEh column.
Set this property to True so that the grid will automatically highlight hyperlinks found in the text.

When you hover over a link with the mouse, the cursor changes to an index finger.
When the mouse clicks on the link, the TColumnEh.OnInCellHyperLinkClick event is called.
The text of the clicked link is passed to the event in the EventArgs.DisplayText variable.
The event handler can use the received text as it sees fit.
Below is an example of an OnInCellHyperLinkClick event handler.
procedure TfrHighlightRefLinks.InCellHyperLinkClick(Grid: TCustomDBGridEh;
EventArgs: TDBGridEhInCellHyperLinkClickEventErgs);
begin
ShowMessage('HyperLinkClick: ' + EventArgs.DisplayText);
end;In the current implementation, the grid defines hyperlinks by the text www…., http://...., https://.....
Other improvements and changes
The Hint property has been added to the TColumnFooterEh class.
Now you can set text hints in the grid footer.
Use the Column[i].Footer.Hint or Columns[i].Footers[fi].Hint property to set hints.
