Creating a MemoView component in Delphi code


I have a report that is constructed in code and is running well, but I need to have one MemoView component that will display two database values. E.g.

MyText := TfrxMemoView.create(MyDataBand);

  MyText.Name := 'TxtUser_Ref';

  MyText.DataSet := frxDBDS_CTSummary;

MyText.DataField:= 'frxDBDSCTSummary.UsersRef' + ' User ID: ' + 'frxDBDS_CTSummary.UserID';

  MyText.Top:= fr1cm * 0;

  MyText.Left := fr1cm * 5.2;

  MyText.Width:= fr1cm * 3.5;

  MyText.Height := MyDataBand.height;

  MyText.StretchMode := smMaxHeight;

  MyText.Font.Size:= 8;

  MyText.Frame.Typ := [ftLeft,ftRight,ftTop,ftBottom];

However, this does not produce the correct result and causes an error (data field cannot be found - I know this is not the right way)

I have tried the following: MyText.Memo. addStrings('<frxDBDSCTSummary."UsersRef">' + ' User ID: ' + '<frxDBDS_CTSummary."UserID">';

This also does not function. Any ideas as how to get the MemoView to display more than one database field?


Tom Dalton


  • Use

    MyText.Memo.Text := '[frxDBDSCTSummary."UsersRef"] User ID: [frxDBDS_CTSummary."UserID"]';

    instead of

    MyText.DataSet := frxDBDS_CTSummary;

    MyText.DataField:= 'frxDBDSCTSummary.UsersRef' + ' User ID: ' + 'frxDBDS_CTSummary.UserID';

  • The fix does not work! I tried it. Paul Gursky also suggested this.

    I have played around with the code a bit and found out that:

    With some testing I figured out that you must not set the Datafield parameter at all. I removed the line of code.

    The reference in the Memo text must include both square brackets to enclose the database field references. 

    MyText.Memo.Text := '[CTSummary."Users_Ref"] User ID: [CTSummary."UserID"]'; //This works!

    The reference to the database field should not be the passed dataset reference e.g. MyText.DataSet := frxDBDS_CTSummary; but rather the actual query name; in this case CTSummary.

    This tested and it does work.




Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.