View Issue Details

IDProjectCategoryView StatusLast Update
0035026LazarusLCLpublic2019-02-07 22:22
ReporterMarkus Müller Assigned Towp  
Status closedResolutionno change required 
Product Version2.1 (SVN) 
Summary0035026: TDBMemo does use the OnGetText property from TField and cannot deactivated
DescriptionIn Laz V1.8.4, the TDBMemo do not use the TField.OnGetText and it show the right plain text from the database.

In the new version from lazarus it was changed by this:

But now, the TDBMemo is showing all the text wrong.
I miss a parameter in the TDBMemo like:
UseFieldGetSetText [boolean]
Without this parameter the use of a TDBMemo with old applications are very difficult and there must overwrite the OnPaint in all other components event.

In Attachment I have post screenshots and a demo projekt where is showing the difference from Lazarus 1.8.x and 2.x when the TField.OnGetText is used
Steps To ReproduceAlways, see demo code, compile it with Lazarus V1.8 and 2.1.
The demo code contain the DLL 64 bit for SQLite and a demo database.
Additional InformationBrunoK want in his BugReport self do a code conversion between the database codepage and UTF8( (Lazarus). But the self written codeconversion is absolutly the badest solution what he can do. The query component itself must know the codepage from the database and do a correct conversion into lazarus. Do it self is bugfully if he want build international software.
The database component ZEOS do this right.

I use:
TDBMemo to showing a text.
TDBGrid to display the Memo-Field, but without the LineBreaks, to see a lot of text in the grid.
The OnGetText() convert the text automaticly for the TDBGrid, but the TDBMemo use the plain text.
But now with Lazarus 2.1, the TDBMemo do display the text without linebreak.

More infos in the german Lazarusforum:
Fixed in Revision
Attached Files


related to 0033498 closedwp TdbMemo does not use property Field.Text to get and store its User interface Text. 
related to 0035037 new TDBMemo, cannot make a custom change from the displayed text 


Markus Müller

2019-02-06 21:22



2019-02-07 07:49

developer   ~0113918

Last edited: 2019-02-07 08:21

View 2 revisions

It is okay, that data-aware controls rely on TField.Text and TField.DisplayText properties. They are intended just for this use.
Value returned by TField.Text/DisplayText can ber altered by user-defined evenr handler in TField.OnGetText.
Your problem is that for TDBGrid you want alter displayed value, but for TDBMemo do not.
I think, that Delphi does it in same way as Lazarus does ... all data-aware controls use TField.Text/DispalyText. (but would be good to check current status of TDBMemo in recent Delphi versions)

In your case you can use temporal hack:

procedure TForm1.ZQuery1ValMemoGetText(Sender: TField; var aText: string;
  DisplayText: Boolean);
var s: string;
  if DisplayText then begin // <--
    s := StringReplace(Sender.AsString, LineEnding, '¶', [rfReplaceAll]);
    s := StringReplace(s, 0000013, '¶', [rfReplaceAll]);
    s := StringReplace(s, 0000010, '', [rfReplaceAll]);
    if Length(s) > 250 then
      aText := UTF8Copy(s, 1, 250) + '...'
      aText := s;
    aText := Sender.AsString;


2019-02-07 08:09

developer   ~0113919

Last edited: 2019-02-07 08:11

View 2 revisions

Btw looking in IMO there are not needed tests like:
           if Assigned(FDataLink.Field.OnGetText) then
             Lines.Text := FDataLink.Field.Text
             Lines.Text := FDataLink.Field.AsString;

Just use always:
             Lines.Text := FDataLink.Field.Text
(because TField.Text calls GetEditText and GetEditText tests for assigned OnGetText() and also TField descendant can override GetText method so we must call always .Text)

Markus Müller

2019-02-07 08:53

reporter   ~0113922

Last edited: 2019-02-07 08:54

View 2 revisions

>> if DisplayText then begin // <--

Thank you very much, yes it works with Lazarus V1.8.x AND V2.1
You have save me a lot of work, my application is very big with a lot of Grids and TDBMemo's.

No changes in Lazarus are required :-)


2019-02-07 09:48



2019-02-07 10:25

developer   ~0113923

Last edited: 2019-02-07 11:40

View 2 revisions

I agree with LacaK that it is not possible to use several string presentations of the same field in different controls.

Just to make sure: demo_delpi_clientdataset is a simplified version of the demo project for Delphi, and in fact, it does show that the text returned by the OnGetText handler is applied to both DBGrid column and DBMemo. The demo, however, shows also than checking for the parameter DisplayText is not a solution any more when the user clicks into the memo cell of the DBGrid. While this does work is Lazarus it is not guaranteed to be like that in the future because it breaks Delphi compatibility.

I think a better solution is to define a calculated string field on the basis of the memo field and do the string calculations for the calculated field in the OnCalcField event of the dataset. Then the DBMemo can use the original memo field while the grid column can use the calculated field. - See demo_laz_bufdataset.


2019-02-07 10:25



2019-02-07 11:41

developer   ~0113925

Resolving, no change required. Please reopen and explain if you are not happy with this decision. Otherwise close the report.

Markus Müller

2019-02-07 21:33

reporter   ~0113930

This solution is not a solution, it is only a bad crack/hack :-/

Issue History

Date Modified Username Field Change
2019-02-06 21:22 Markus Müller New Issue
2019-02-06 21:22 Markus Müller File Added:
2019-02-06 21:29 Markus Müller Tag Attached: TDBMemo
2019-02-07 07:49 LacaK Note Added: 0113918
2019-02-07 07:51 LacaK Relationship added related to 0033498
2019-02-07 08:09 LacaK Note Added: 0113919
2019-02-07 08:11 LacaK Note Edited: 0113919 View Revisions
2019-02-07 08:21 LacaK Note Edited: 0113918 View Revisions
2019-02-07 08:53 Markus Müller Note Added: 0113922
2019-02-07 08:54 Markus Müller Note Edited: 0113922 View Revisions
2019-02-07 09:18 wp Assigned To => wp
2019-02-07 09:18 wp Status new => assigned
2019-02-07 09:36 wp File Added:
2019-02-07 09:48 wp File Deleted:
2019-02-07 09:48 wp File Added:
2019-02-07 10:25 wp Note Added: 0113923
2019-02-07 10:25 wp File Added:
2019-02-07 11:40 wp Note Edited: 0113923 View Revisions
2019-02-07 11:41 wp LazTarget => -
2019-02-07 11:41 wp Note Added: 0113925
2019-02-07 11:41 wp Status assigned => resolved
2019-02-07 11:41 wp Resolution open => no change required
2019-02-07 21:33 Markus Müller Note Added: 0113930
2019-02-07 21:33 Markus Müller Status resolved => closed
2019-02-07 22:22 Michl Relationship added related to 0035037