Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Preventing Address printing blank spaces

edited May 2002 in General
I am using a memo for my address so any address fields that do not contain a
value will not be printed as a blank space.
I use the following code (which i got from your help).

ppTestMemo.Lines.Clear;
lsLine :=
dmDbiSoloAccMan.cdsAccounts.FieldByName('AccountName').AsString;;
ppTestMemo.Lines.Add(lsLine);

lsLine := dmDbiSoloAccMan.cdsAccounts.FieldByName('Address1').AsString;
if lsLine <> '' then
ppTestMemo.Lines.Add(lsLine);

lsLine := dmDbiSoloAccMan.cdsAccounts.FieldByName('Address2').AsString;
if lsLine <> '' then
ppTestMemo.Lines.Add(lsLine);

My question is how can i make only the Address1 value bold ?
So i would have some fields not bold and some that are bold.
Is this possible ?
Is so, then i could really do with some advice on how to go about it.
Many thanks
John

Comments

  • edited May 2002
    Use the RichText component rather than the Memo component as the latter
    allows only one font for the entire text.

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

  • edited May 2002

  • edited May 2002
    Ok, I've changed to a RichText component but how do i go about making the
    second line bold ?
    Thanks
    John


    "Alexander Kramnik (Digital Metaphors)" wrote
  • edited May 2002
    Use the standard richtext capabilities (SelStart, SelLength, etc.) to
    format the richtext content.

    Some sample code is included below.

    Cheers,

    Tom Ollar
    Digital Metaphors Corporation


    {---------------------------------------------------------------------------
    ---}
    {Tfrm0029.ppRichText1Print}

    procedure Tfrm0029.ppRichText1Print(Sender: TObject);
    var
    liSelStart: Integer;
    liSelEnd: Integer;
    liSelLength: Integer;
    liSpace: Integer;
    liFish: Integer;
    begin


    {assign the text from the memo to the ppRichText component}
    ppRichText1.RichText := tblBioLife.FieldByName('Common_Name').AsString +
    #13 + #13 +
    tblBioLife.FieldByName('Notes').AsString;

    {assign default font to all text }
    ppRichText1.SelectAll;
    ppRichText1.SelAttributes.Assign(FDefaultFont);

    {assign title font to the fish name }
    liSelLength := Length(tblBioLife.FieldByName('Common_Name').AsString);

    ppRichText1.SelStart := 0;
    ppRichText1.SelLength := liSelLength;
    ppRichText1.SelAttributes.Assign(FTitleFont);


    { italize the the first word in the paragraph

    note: FindText(const SearchStr: string; StartPos, Length: Integer;
    Options: TSearchTypes):Integer; }

    liSpace := ppRichText1.FindText(' ', liSelLength+4, 30,[]);
    ppRichText1.SelStart := liSelLength+2;
    ppRichText1.SelLength := liSpace - ppRichText1.SelStart;
    ppRichText1.SelAttributes.Size := 14;
    ppRichText1.SelAttributes.Style := [fsBold, fsItalic];


    {make the first letter in the paragraph size 16 and bold italic}
    ppRichText1.SelStart := liSelLength+2;
    ppRichText1.SelLength := 1;
    ppRichText1.SelAttributes.Size := 16;
    ppRichText1.SelAttributes.Style := [fsBold, fsItalic];


    {underline all occurances of the word 'fish' in blue}
    ppRichText1.SelectAll;
    liSelEnd := ppRichText1.SelLength;
    liSelStart := liSelLength+4;

    while liSelStart < liSelEnd do
    begin
    liFish := ppRichText1.FindText('fish', liSelStart, liSelEnd,[]);

    if liFish < 0 then Break;

    {color the text blue}
    ppRichText1.SelStart := liFish;
    ppRichText1.SelLength := liFish + 4;
    ppRichText1.SelAttributes.Color := clBlue;
    ppRichText1.SelAttributes.Style := [fsUnderLine];

    {re-assign the defaul font attributes to the remaining text}
    ppRichText1.SelStart := liFish + 5;
    ppRichText1.SelLength := liSelEnd;
    ppRichText1.SelAttributes.Assign(FDefaultFont);

    liSelStart := ppRichText1.SelStart + 5;

    end;

    end;
This discussion has been closed.