Adding component at runtime
Hi,
I am trying to add a new component to my report at runtime. Effectively
I have some TppDBMemo fields on the form, and if they have no text
assigned to them, I would like a diagonal line to go through them.
To do this (without having to manually add diagonal lines at designtime
and then create code to hide/show them at run time), I have created code
that is ran prior to the report that will scan through the specified
TppDBMemo fields, and if one is found that matches, a corresponding line
should be created that strikes through that area of the report.
However - this is not working for me. The code executes fine, and
appears to create the component (when looking through debugging the
code), but no line physically appears on my report.
I was wondering if someone could please advise where I have gone wrong.
The code I am using to create the vertical line is as follows:
procedure CreateStrike(Component: TppComponent);
var
myline : TppLine;
begin
myline := tppLine.Create(Component.owner);
myline.Top := Component.Top;
myline.Left := Component.Left;
myline.Height := Component.Height;
myline.Width := Component.Width;
myline.position := lpDiagRight;
myline.Tag := 21;
end;
...where I send the component I wish to strike when calling the procedure.
Can someone please let me know what I am missing?
Thanks & Regards
Adam.
I am trying to add a new component to my report at runtime. Effectively
I have some TppDBMemo fields on the form, and if they have no text
assigned to them, I would like a diagonal line to go through them.
To do this (without having to manually add diagonal lines at designtime
and then create code to hide/show them at run time), I have created code
that is ran prior to the report that will scan through the specified
TppDBMemo fields, and if one is found that matches, a corresponding line
should be created that strikes through that area of the report.
However - this is not working for me. The code executes fine, and
appears to create the component (when looking through debugging the
code), but no line physically appears on my report.
I was wondering if someone could please advise where I have gone wrong.
The code I am using to create the vertical line is as follows:
procedure CreateStrike(Component: TppComponent);
var
myline : TppLine;
begin
myline := tppLine.Create(Component.owner);
myline.Top := Component.Top;
myline.Left := Component.Left;
myline.Height := Component.Height;
myline.Width := Component.Width;
myline.position := lpDiagRight;
myline.Tag := 21;
end;
...where I send the component I wish to strike when calling the procedure.
Can someone please let me know what I am missing?
Thanks & Regards
Adam.
This discussion has been closed.
Comments
In order to add the line to the report, you need to assign it's Band or
Region property. For instance if the memo is in the detail band, you
would add the line:
myLine.Band := Report.DetailBand;
You also need to be sure you are calling this code before that band has
started generating.
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Bingo! I knew it was going to be something simple I overlooked.
Thanks very much for your reply and help. Greatly appreciated! Have a
great weekend!
Adam.