How do I load an image from a TImageList to a Graphics field? lazarus / 39-Graphics ---------------------------------------------------------------------- RedOctober · 2018-01-28 23:43 Platform: Windows Server 2016, Laz 1.8.1, FPC 3.0.5 I have created a calculated TGraphicField in a TSQLQuery calle "IsActv". I have a TImageList with two .png s in it... a green check and a red dot. I have a string field that will contain either of the values 'GREEN_CHECK' or 'RED_DOT'. How do I assign the green dot graphic in the TImageList to the calculated graphics field? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TfrmDBTrigs.qryLstCalcFields(DataSet: TDataSet);begin  if qryLstSHOW_IMAGE.AsString = 'GREEN_DOT' then    qryLstIsActv.  ???  // <-- ImgLst.  ?? items[0] ??  else    qryLstIsActv.  ???  // <-- ImgLst.  ?? items[1] ??end;  What is the syntax that should replace the ???  characters? ---------------------------------------------------------------------- Josh · 2018-01-29 00:45 Hi Done a quick demo of assigning an image.bitmap from an imagelist index. Hopefully it may help. Using your example something along the lines of var gr_idx:integer=0; .... begin ....   gr_idx:=0;  // default to green   if qryLstSHOW_IMAGE.AsString = 'RED_DOT' then gr_idx:=1;   imagelist1.GetBitmap(gr_idx,qryLstIsActv.Picture.Bitmap); // assuming qryLstIsActv is a timage. .... end; ---------------------------------------------------------------------- RedOctober · 2018-01-29 01:16 Hi Josh, qryLstIsActv is a TGraphicField.  There is no .Picture property and no Picture.Bitmap property. Hence my original question. ---------------------------------------------------------------------- balazsszekely · 2018-01-29 08:23 @RedOctober Change TGraphicField to TLargeintField then: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TfMain.DBGridDrawColumnCell(Sender: TObject; const Rect: TRect;  DataCol: Integer; Column: TColumn; State: TGridDrawState);var  Bmp: TBitmap;begin  if DataCol = 0 then  begin    Bmp := TBitMap.Create;  try      ImageList1.GetBitmap(TDBGrid(Sender).DataSource.DataSet.Field ByName('IsActv').AsInteger, Bmp);      Bmp.Canvas.Draw(0, 0, Bmp);    TDBGrid(Sender).Canvas.Draw(Rect.Left + 2, Rect.Top + 2, Bmp);    finally      Bmp.Free;    end;  end;end; procedure TfMain.qryLstIsActvCalcFields(DataSet: TDataSet);begin  if not Dataset.Active then    Exit;   if qryLstSHOW_IMAGE.AsString = 'GREEN_DOT' then     DataSet.FieldByName('IsActv').AsInteger := 0   else     DataSet.FieldByName('IsActv').AsInteger := 1end; procedure TfMain.qryLstIsActvIsactvGetText(Sender: TField; var aText: string;  DisplayText: Boolean);begin  aText := '';end;         PS: You can generate the last event "qryLstIsActvIsactvGetText" by  doubleclicking the query-->select calc field isact-->OI events.