Recent

Author Topic: Lazreport changing fonts at runtime  (Read 10289 times)

ahiggins

  • Jr. Member
  • **
  • Posts: 92
Lazreport changing fonts at runtime
« on: January 29, 2012, 07:36:50 pm »
Is there an easy way to change the font at runtime.

If View.Name='Memo14' then
     begin
          If TitleBar Then View.FillColor:=clSilver else
          View.FillColor:=clWhite;
          If TitleBar Then View.Width:=696 else View.Width:=400;
     end;

as well as changing the colour and width i would also like to change the font to bold

Lam.Abdeldjalil

  • Newbie
  • Posts: 6
Re: Lazreport changing fonts at runtime
« Reply #1 on: January 29, 2012, 10:39:44 pm »
hi ,

try it this way

Code: [Select]
(frReport1.Pages.Pages[0].FindObject('memo14') as TfrMemoView).Font.Size:=20;
(frReport1.Pages.Pages[0].FindObject('memo14') as TfrMemoView).Width:=200;

good luck ;

ahiggins

  • Jr. Member
  • **
  • Posts: 92
Re: Lazreport changing fonts at runtime
« Reply #2 on: January 31, 2012, 11:47:42 am »
many thanks for the reply. But i cant get it to work. Im not sure what im doing wrong but i just can't change the fonts bold status at runtime, any ideas?
I've found a dirty work around, i used two memos overlayed on top of each other, one bold one not, then  just switch the visible status of them both depending if Titlebar is true or not.   

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Lazreport changing fonts at runtime
« Reply #3 on: January 31, 2012, 12:50:48 pm »
Did yo try:

(frReport1.Pages.Pages[0].FindObject('memo14') as TfrMemoView).Font.Style:=[fsBold];

?

ahiggins

  • Jr. Member
  • **
  • Posts: 92
Re: Lazreport changing fonts at runtime
« Reply #4 on: January 31, 2012, 02:31:21 pm »
Just tried it, still no joy. looks like i will have to stick with the dirty workaround. Oh I'd just like the thank everyone who works on the Free Pascal & Lazarus projects. I use the both of them every day at work, and am still amazed  the power these tools provide. Many thanks.

cristianorta

  • Newbie
  • Posts: 5
Re: Lazreport changing fonts at runtime
« Reply #5 on: February 22, 2013, 03:56:45 am »
Sorry for my bad English!
If i put the code:
if x=true then
       (frReport1.Pages.Pages[0].FindObject('Memo4') as TfrMemoView).Font.Style:=
                 (frReport1.Pages.Pages[0].FindObject('Memo4') as TfrMemoView).Font.Style+[fsBold];
in OnGetValue Memo4 is always bold but if i put the code:
if x=true then
       (frReport1.Pages.Pages[0].FindObject('Memo4') as TfrMemoView).Font.Style:=
                 (frReport1.Pages.Pages[0].FindObject('Memo4') as TfrMemoView).Font.Style+[fsBold]
else
       (frReport1.Pages.Pages[0].FindObject('Memo4') as TfrMemoView).Font.Style:=
                 (frReport1.Pages.Pages[0].FindObject('Memo4') as TfrMemoView).Font.Style-[fsBold];
Memo4 is never bold.

What am i doing wrong?

cristianorta

  • Newbie
  • Posts: 5
Re: Lazreport changing fonts at runtime
« Reply #6 on: March 20, 2013, 04:04:25 am »
To change fonts at runtime put code in LazReport Memo Field.

if [repoDS."IzqResaltado"]=true then FontStyle:=2 else FontStyle:=0;

Thanks to Profesor Carlos

http://professorcarlos.blogspot.com.ar/2010/06/lazarus-dicas-de-lazreport.html

JP.NUAGE

  • Newbie
  • Posts: 1
Re: Lazreport changing fonts at runtime
« Reply #7 on: November 26, 2013, 09:48:54 am »
Sorry for that, but I'm afraid this code doesn't work
I code in the Memo Script

Memo13.Visible := [MYTABLE."CASH"] <> 0;
if [MYTABLE."CASH"] < 0 then
  FontStyle := 2;

Then I tried

Memo13.Visible := [MYTABLE."CASH"] <> 0;
if [MYTABLE."CASH"] < 0 then
  Memo13.FontStyle := 2;

For null values, Memo13 is invisible. But for negative values, no change is to be seen on the report

What did I do wrong ?
 

 

TinyPortal © 2005-2018