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

how do I centre the text in a TppRichText control at runtime ?

edited June 2007 in General
Using Delphi 7 and 10.06 Enterprise

If I want to programmatically populate a TppRichText control at runtime, how
do I centre the text ? By default it starts from the left. At the moment I'm
using the following code:

procedure TMainForm.ApplyFilterText (const sFilterText : string ; theCtrl :
TppReport) ;
var
iCnt : integer ;
rtCtrl : TppRichText ;

begin
if theCtrl.TitleBand.ObjectByName (iCnt, ksReportFilter) then
begin
rtCtrl := theCtrl.TitleBand.Objects [iCnt] as TppRichText ;
rtCtrl.Font.Name := 'Arial' ;
rtCtrl.Font.Size := 9 ;

rtCtrl.RichText := sFilterText ;
end ;
end ;

Comments

  • edited June 2007
    do you have RAP? If so, you might want to use a pass through function.

    --
    Ed Dressel
    Team DM
  • edited June 2007
    Hello,

    I checked some earlier posts (I should have done that before I posted mine,
    sorry) and have now sorted my problem. Shown below is the function I am
    using in hope that it may help others.

    procedure TMainForm.ApplyFilterText (const sFilterText : string ; theCtrl :
    TppReport) ;
    var
    iCnt : integer ;
    rtCtrl : TppRichText ;

    begin
    if theCtrl.TitleBand.ObjectByName (iCnt, ksReportFilter) then
    begin
    rtCtrl := theCtrl.TitleBand.Objects [iCnt] as TppRichText ;

    rtCtrl.RichText := sFilterText ;
    rtCtrl.SelectAll ;

    rtCtrl.SelAttributes.Color := clNavy ;
    rtCtrl.SelAttributes.Name := 'Arial' ;
    rtCtrl.SelAttributes.Size := 10 ;
    rtCtrl.SelAttributes.Style := [fsBold] ;
    rtCtrl.Paragraph.Alignment := taCenter ;
    end ;
    end ;


This discussion has been closed.