Thema: Delphi TStringGrid inner margin

Einzelnen Beitrag anzeigen

marabu

Registriert seit: 6. Apr 2005
10.109 Beiträge
 
#3

Re: TStringGrid inner margin

  Alt 8. Feb 2006, 18:36
Welcome to our community, Silvia.

The gap you object to is produced by the default drawing method of the cell. If you have an event handler for the OnDrawCell() event you can set horizontal and vertical gaps at will:

Delphi-Quellcode:
procedure TDemoForm.StringGridDrawCell(Sender: TObject; ACol,
  ARow: Integer; Rect: TRect; State: TGridDrawState);
const
  hGap = 0;
  vGap = 0;
begin
  with Sender as TStringGrid do
  begin
    Canvas.FillRect(Rect);
    TextOut(Canvas.Handle, Rect.Left + hGap, Rect.Top + vGap,
      PAnsiChar(Cells[ACol, ARow]), Length(Cells[ACol, ARow]));
  end;
end;
Kind regards

marabu
  Mit Zitat antworten Zitat