placing TppImage into TableGrid cell dynamically
I am adding a TppImage to a table grid, so:
lTableGrid.Cells[0, 0].AddChild(img);
However, the TppImage does not seem to be bound to the limits of the
cell. If I set img.ParentWidth to True, then the image becomes much
smaller than the cell, which is puzzling.
Also, I see that in the report designer, if I place a TableGrid, then
place a TppImage into one of the cells, the TppImage width is limited
by the cell, but the height is not.
So overall, my qeustion is how to constrain the TppImage to the
confines of a single cell.
Thanks,
Bill
lTableGrid.Cells[0, 0].AddChild(img);
However, the TppImage does not seem to be bound to the limits of the
cell. If I set img.ParentWidth to True, then the image becomes much
smaller than the cell, which is puzzling.
Also, I see that in the report designer, if I place a TableGrid, then
place a TppImage into one of the cells, the TppImage width is limited
by the cell, but the height is not.
So overall, my qeustion is how to constrain the TppImage to the
confines of a single cell.
Thanks,
Bill
This discussion has been closed.
Comments
Below is a code example.
- to add an image to a cell, set Image.Parent Never call AddObjects. When
creating layouts via code, always set Band.Report to add a Band, set
Object.Band or Object.Parent to add an object to a band or container.
- to align the image, use the Image.Anchors property. The cell aligns its
child object based on their Anchors.
- use the Cell.Padding property if you need to increase/decrease the amount
of space between the cell boundary and its child objects.
This is all covered in the help topics for TppTableGrid, TppTableCell,
TppTableRow, TppTableColumn. Hope you get the help installed
uses
ppTypes;
procedure TForm1.Button1Click(Sender: TObject);
var
lImage: TppImage;
begin
// create a grid with 2 rows and 3 columns
FTableGrid := TppTableGrid.Create(Self);
FTableGrid.Band := ppReport1.Detail;
FTableGrid.Left := 2;
FTableGrid.RowCount := 2;
FTableGrid.ColCount := 3;
// add an image to the first grid cell, configure the anchors to occupy
the entire cell
lImage := TppImage.Create(Self);
lImage.Parent := FTableGrid.Cells[0,0];
lImage.Anchors := [atLeft, atTop, atRight, atBottom];
end;
Best regards,
-
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
Nard,
Thanks for your assistance. I was using AddChild() to put the image
in the cell, but am now setting the parent, instead. I found that
setting the image Anchors to [atBottom] does put the image in the
bottom of the cell, but oddly, setting to [atTop] does not place it in
the top of cell, but leaves it mid-cell, vertically. I have not
assigned padding, and the single row grid height is set to the band
height, which is 1.5". The image height is 1.25", so there is room for
it to be at the top or bottom, without confusion. There is no other
object in the cell, and I am at my wits end trying to discover what
prevents me moving the image aboge the vertical center of cell.
I have not been able to install the help. It seems I must re-install
RB15.03 in its entirety, in order to do so, and I am not keen to go
down that path at the moment, as I am pulled in several directions. But
perhaps tomorrow.
Thanks,
Bill
Try creating a new test project. Start with the example code I provided,
which works in my testing here. Make sure that exact code works. Then
incrementally modify the code to demonstrate what you are trying to
accomplish. If you can create the issue, then zip and send to support@.
Use this link to download the RBuilder help file in HtmlHelp format (I just
generated an update)
http://digital-metaphors.com/download/online_help.html
Best regards,
-
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
Nard,
I found that handling the scaling of an image is interesting. I
enabled borders around the image and as they did not outline the border
of the graphic content, but a larger space, I was able to locate the
issue, and correct it.
I may yet need to produce a small project to send to support, but not
yet.
Thanks,
Bill