Subject Re: [IBO] Display Icons in TIB_Grid
Author Florian Hector
> How can i display Icons/Symbols in an TIB_Grid, for example, i have an
> integer field and i want not to display the values, i want to display an
> Symbol/icon and the icons are stored in an Bitmap List no in the table
> directly.
> In my case i have 10 different values 1 till 10 and every value is
> assigned to an special icon.
>
> I searched the help files, but i found nothing about that.

Following a routine from one of my applications. Though it gets the
bitmap from a query it should not be a problem to modify it to fit your
needs.

procedure TfrmOptionen.grdCompressSettingsDrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
var
sFieldName : String;
bmp : TBitmap;
iLeftMargin: Integer;
iTopMargin : Integer;
DrawRect : TRect;
begin
// locate the record that corresponds to the cell that is to be drawn
DM.qrySettings.BufferRowNum := grdCompressSettings.DataRow[ARow];
// get fieldname
sFieldName :=
upperCase(grdCompressSettings.GridFields[ACol-1].FieldName);
if (sFieldName = 'BESCHREIBUNG') and
DM.qrySettings.BufferFieldByName('Extension').IsNotNull then
begin
// Cell-Bereich um die Cell-Rand-Linie verkleinern
Rect.Left := Rect.Left + 1;
Rect.Right := Rect.Right - 1;
Rect.Top := Rect.Top + 1;
Rect.Bottom := Rect.Bottom - 1;
// fill background
grdCompressSettings.Canvas.FillRect(Rect);
// Icon
bmp := TBitmap.Create;
try
DM.qrySettings.BufferFieldByName('Icon').AssignTo(bmp);
iLeftMargin := 1;
iTopMargin := ((Rect.Bottom-Rect.Top) - bmp.Height) div 2;
DrawRect := Bounds( Rect.Left+iLeftMargin, Rect.Top+iTopMargin,
bmp.Width, bmp.Height );
grdCompressSettings.Canvas.BrushCopy(DrawRect, bmp, Bounds(0, 0,
bmp.Width,bmp.Height),
bmp.TransparentColor);
grdCompressSettings.Canvas.TextOut(Rect.Left + bmp.Width + 5,
Rect.Top, DM.qrySettings.BufferFieldByName ('Beschreibung').AsString);
finally
bmp.Free;
end;
end;
end;



Good luck

Florian