Subject | Re: [IBO] Image in a Grid |
---|---|
Author | Markus Ostenried |
Post date | 2014-03-02T15:48:47Z |
Hi,
I found some old code which might help you:
Regards,
Markus
{
var
gr_RezCli: TIB_Grid;
gr_RezCli.OnDrawCell := gr_RezCliDrawCell;
}
// draw icon in cell if field REZ_MEMO is not empty
procedure TW_Rez.gr_RezCliDrawCell( Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState );
var
sFieldName : String;
bmp : TBitmap;
iLeftMargin: Integer;
iTopMargin : Integer;
DrawRect : TRect;
begin
if (gdFixed in State) or
not Assigned(gr_RezCli) or
not Assigned(gr_RezCli.GridFields[ACol-1]) or
not Assigned(W_DM_Rez) or
not Assigned(W_DM_Rez.D_Rez_Cli) or
not Assigned(W_DM_Rez.Q_Rez_Cli) or
//not W_DM_Rez.Q_Rez_Cli.Prepared or
not W_DM_Rez.Q_Rez_Cli.Active or
W_DM_Rez.Q_Rez_Cli.FieldByName('ID_REZEPT').IsNull or
(W_DM_Rez.Q_Rez_Cli.RecordCount < 1) then
begin
exit;
end;
try
W_DM_Rez.Q_Rez_Cli.BufferRowNum := gr_RezCli.DataRow[ARow];
sFieldName := UpperCase( gr_RezCli.GridFields[ACol-1].FieldName );
if (sFieldName = 'REZ_MEMO') and
not W_DM_Rez.Q_Rez_Cli.BufferFieldByName('REZ_MEMO').IsNull then
begin
// inflate rect by line width
Rect.Left := Rect.Left + 1;
Rect.Right := Rect.Right - 1;
Rect.Top := Rect.Top + 1;
Rect.Bottom := Rect.Bottom - 1;
// fill background
gr_RezCli.Canvas.FillRect( Rect );
// icon
bmp := TBitmap.Create;
try
// load bitmap from resource
Bingo_LoadBitmapByIdent( imgDateInfo, bmp );
// center icon
iLeftMargin := ((Rect.Right-Rect.Left) - bmp.Width) div 2;
iTopMargin := ((Rect.Bottom-Rect.Top) - bmp.Height) div 2;
DrawRect := Bounds( Rect.Left+iLeftMargin, Rect.Top+iTopMargin, bmp.Width, bmp.Height );
// draw icon
gr_RezCli.Canvas.BrushCopy( DrawRect, bmp, Bounds(0, 0, bmp.Width, bmp.Height),
bmp.TransparentColor );
finally
bmp.Free;
end;
end;
except
on E: Exception do begin
// log stuff
end;
end;
end;
On Sun, Mar 2, 2014 at 3:30 PM, Jack Cane <jwcane@...> wrote:Have you found a solution to this?
Best,jwcOn Feb 21, 2014, at 1:08 AM, Alexandre <alexandrepires2000@...> wrote: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