Invalid Typecast
I thought that I had this problem solved but I was wrong. I have the
following code:
begin
for i := 0 to TheForm.ComponentCount - 1 do
if ( TheForm.Components[i] is TppDBText ) then
(TheForm.Components[i] as TppDBText).TextAlignment :=
taRightJustified;
end;
I get an invalid typecast error on the line:
(TheForm.Components[i] as TppDBText).TextAlignment := taRightJustified;
I using Delphi 6, ReportBuilder 10.09, Windows Vista Ultimate.
following code:
begin
for i := 0 to TheForm.ComponentCount - 1 do
if ( TheForm.Components[i] is TppDBText ) then
(TheForm.Components[i] as TppDBText).TextAlignment :=
taRightJustified;
end;
I get an invalid typecast error on the line:
(TheForm.Components[i] as TppDBText).TextAlignment := taRightJustified;
I using Delphi 6, ReportBuilder 10.09, Windows Vista Ultimate.
This discussion has been closed.
Comments
1. Rather than looping through the components on the form to find a report
component, I would suggest using a report object loop.
http://www.digital-metaphors.com/rbWiki/Delphi_Code/Layouts/Report_Object_Loop
2. Try typecasting in the following manner...
uses
ppCtrls, ppTypes;
--
if(myObject is TppDBText) then
TppDBText(MyObject).TextAlighment := taRightJustified;
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
That worked. Thanks again for your excellent support.
Regards,
Al