Adding textfield to a region at runtime
I'm adding TppDBText components to a TppRegion at runtime like this:
----------------------------------------
lIDFieldRegion := TppRegion(FCurrentReport.DetailBand.FindUserObject('IDFieldsRegion'));
lTextField := TppDBText(ppComponentCreate(lIDFieldRegion, TppDBText));
//Adding properties of lTextField here
with lTextField do
begin
Left := lIDFieldRegion.Left + i * lTextFieldWidth;
Width := lTextFieldWidth - 1;
Top := lIDFieldRegion.Top;
Height := lIDFieldRegion.Height;
Font.Name := 'Arial';
Font.Size := 10;
DataPipeline := FPipeline;
DataField := 'Details.' + FCurrentIDFields.Selected.Items[i].FieldName;
end;
--------------------------------------
But this doesnt produce the field on the report.
What strikes me is that after the call to ppComponentCreate, the Parent property
of the new textfield is still nil, while I specify the region object as the
parent
Why is this?
Another thing that looks strange to me, is the fact that child objects of
i.e. a region, have absolute top and left properties, in stead of relative
to their parent. So if i move the region, aren't the objects inside the region
moved?
Greetings
Bas
----------------------------------------
lIDFieldRegion := TppRegion(FCurrentReport.DetailBand.FindUserObject('IDFieldsRegion'));
lTextField := TppDBText(ppComponentCreate(lIDFieldRegion, TppDBText));
//Adding properties of lTextField here
with lTextField do
begin
Left := lIDFieldRegion.Left + i * lTextFieldWidth;
Width := lTextFieldWidth - 1;
Top := lIDFieldRegion.Top;
Height := lIDFieldRegion.Height;
Font.Name := 'Arial';
Font.Size := 10;
DataPipeline := FPipeline;
DataField := 'Details.' + FCurrentIDFields.Selected.Items[i].FieldName;
end;
--------------------------------------
But this doesnt produce the field on the report.
What strikes me is that after the call to ppComponentCreate, the Parent property
of the new textfield is still nil, while I specify the region object as the
parent
Why is this?
Another thing that looks strange to me, is the fact that child objects of
i.e. a region, have absolute top and left properties, in stead of relative
to their parent. So if i move the region, aren't the objects inside the region
moved?
Greetings
Bas
This discussion has been closed.
Comments
When adding a component to a region, you need to define the
TppComponent.Region property. Likewise when adding a component to a band
you need to assign its Band property to the proper band.
I also highly recommend gaining access to any existing components on the
report using a report object loop rather than the FindUserObject routine
used below.
http://www.digital-metaphors.com/rbWiki/Delphi_Code/Layouts/Report_Object_Loop
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com