#1 2024-12-02 01:22:36

Sapiem
Member
Registered: 2017-12-08
Posts: 64

TStringGrid.onDrawCell is not loaded when TSQLTableToGrid.Create

I have a TStringGrid to which I assign values via a TSQLTableToGrid.Create. Apparently onDrawCell is only called when the headers are assigned. When the records are displayed, it is never called.
I need to draw an icon un first column. How can I do it?

procedure TFMain.ListaPtesDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
var
 IconIndex: Integer;
begin
   try
      if ACol = 0 then
         begin
            IconIndex := ListaPtes.Cells[0,ARow].ToInteger; // ARow; // Assuming each row has a different icon
            ImageList1.Draw(ListaPtes.Canvas, Rect.Left + 2, Rect.Top + 2, IconIndex);
         end
      else
         begin
            ListaPtes.Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, ListaPtes.Cells[ACol, ARow]);
         end;
   except
   //
   end;
end;

// Code of show registers
      fGrid := TSQLTableToGrid.Create(ListaPtes, TableTemp, nil);
      fGrid.SetAligned([3, 3], alCenter);
      fGrid.DrawGrid.ColWidths[0] := 30;
      fGrid.DrawGrid.ColWidths[1] := 300;
      fGrid.DrawGrid.ColWidths[2] := 250;
      fGrid.DrawGrid.ColWidths[3] := 100;
      fGrid.DrawGrid.ColWidths[4] := 100;
      fGrid.DrawGrid.ColWidths[5] := -1;

      Application.ProcessMessages;

Offline

Board footer

Powered by FluxBB