Setting font values in code
Hi,
I want to set the font of a field in a report to bold based on data using
the BeforePrint trigger.
My psudo code for the trigger is
if(TestValue.value ='B')then
FieldName.font.style??? :=TRUE; // Sets field BOLD
What is the exact syntax to set the field to Bold ?
Thanks
Les Fox
I want to set the font of a field in a report to bold based on data using
the BeforePrint trigger.
My psudo code for the trigger is
if(TestValue.value ='B')then
FieldName.font.style??? :=TRUE; // Sets field BOLD
What is the exact syntax to set the field to Bold ?
Thanks
Les Fox
This discussion has been closed.
Comments
It should be the same as the standard Delphi code to include fsBold to
the style:
if (TestValue.Value = 'B') then
FieldName.Font.Style := FieldName.Font.Style + [fsBold];
(I can't verify this, as I'm not sure what type of component
"FieldName" actually is in the code snipped you provided.)
Since RAP does not allow the use of sets, we added properties to TFont to
allow you to set these values in code. Normally for a Set type property such
as TFont.Style, you might use the Include and Exclude procedures to change
its value. In RAP, however, we have added the following boolean properties
to TFont for this purpose: Bold, Italic, Normal, Underline and Strikeout. To
set a font to bold in RAP, you would say myFont.Bold := True. Likewise to
remove style specifications from a font, you would say myFont.Normal :=
True.
If you are using Delphi see Jon Robertson's reply to your post. This is the
correct way to set the font style in Delphi code.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
I am using Delphi code not RAP so you put me on the right track Jon.
Adding and subtracting [fsBold] to turn bolding ON and OFF works well.
Many thanks for your help.
Best wishes,
Les Fox
You can't use Include and Exclude on properties. I've never
understood why Delphi doesn't call the Getter, do the Include/Exclude
on the result, then send it to the Setter. But alas...