Subject RE: [IBO] Image in a Grid
Author Dmitry A. Beloshistov
Hi.

You can rewrite DefaultDrawCell() method for your grid.

procedure YOURGRID.DefaultDrawCell(ACol, ARow: Integer; ARect: TRect;
AState: TGridDrawState; CellDisplayText: string;
CellAlignment: TAlignment);
var AColumn:TIB_Column;
tmpInt:integer;
Indicator:integer;
Flag:boolean;
begin
inherited;
// try get info about current column and dataset state.....

AColumn := nil;
if DataLink.Prepared then
begin
if ((not Self.RowSelect and (DataLink.ActiveRecord=DataRow[ARow])) or
(DataLink.BufferRowCount=0)) then AColumn:=GridFields[DataCol[ACol]]
else begin
if ARow>=FixedRows then DataLink.BufferRecord:=DataRow[ARow]
else DataLink.BufferRecord:=DataRow[FixedRows];
if Datalink.BDataset.BufferFields.RowState<>rsNone then
AColumn:=BuffFields[DataCol[ACol]];
end;
end;
if Assigned(DataSource) and Assigned(DataSource.Dataset) then
Flag:=DataSource.Dataset.BufferRowCount>0
else Flag:=False;

// and now - try write image - I`m put image into FColumnImages (it`s TImageList)....
// Indicator - index of need image, what we want paint

if (ARow>=FixedRows) and Assigned(AColumn) and Flag then
begin
Indicator:=100; // try paint image with index 100 from TImageList
// you can write own method for get image index or not use TImageList for paint
if (Indicator>=0) and (Indicator<FColumnImages.Count) then // index correct?
begin
WriteText(Canvas,ARect,1,1,EmptyStr,taLeftJustify); // write empty text
with FColumnImages do
begin
BkColor:=Canvas.Brush.Color;
with ARect do
begin
if (Right-Left)>Width then
begin
tmpInt:=(Right-Left-Width) shr 1;
Inc(Left,tmpInt);
Dec(Right,tmpInt);
end;
Draw(Canvas,Left,(Top+Bottom-Height) shr 1,Indicator); // paint image in cell
end;
end;
end;
end;
end;

From: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com] On Behalf Of Alexandre
Sent: Friday, February 21, 2014 8:09 AM
To: IBObjects@yahoogroups.com
Subject: [IBO] Image in a Grid



I Guys,
Exist some way to display external images in a grid columns when the
data source only contains links to the images ? In my data base only
have the link, but I need show the image inside of the grid.
Exist some way to do this with IBO ?

Thanks
Alexandre



[Non-text portions of this message have been removed]