{
Bu islemle ilgili bir ornek program Programlar bolumunde
bulunmaktadir
}
procedure DrawCell(const Value: String; const Rect: TRect;
vCanvas: TCanvas; vFont: TFont; vAlignment: TAlignment);
VAR X : Integer;
BEGIN
vCanvas.Font := vFont;
CASE vAlignment OF
taRightJustify : BEGIN
SetTextAlign(vCanvas.Handle, TA_RIGHT);
X := Rect.Right-2;
END;
taLeftJustify : BEGIN
SetTextAlign(vCanvas.Handle, TA_LEFT);
X := Rect.Left+2;
END;
taCenter : BEGIN
SetTextAlign(vCanvas.Handle, TA_CENTER);
X := (Rect.Right+Rect.Left) DIV 2;
END;
END;
vCanvas.TextRect(Rect, X, Rect.Top+2, Value);
SetTextAlign(vCanvas.Handle, TA_LEFT);
END;
// Kullanimi: (StringGrid1.OnDrawCell event handler'i)
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
case ACol of
1:
DrawCell((Sender as TStringGrid).Cells[ACol, ARow], Rect, (Sender as TStringGrid).Canvas,
(Sender as TStringGrid).Font, taRightJustify);
2:
DrawCell((Sender as TStringGrid).Cells[ACol, ARow], Rect, (Sender as TStringGrid).Canvas,
(Sender as TStringGrid).Font, taCenter);
3:
DrawCell((Sender as TStringGrid).Cells[ACol, ARow], Rect, (Sender as TStringGrid).Canvas,
(Sender as TStringGrid).Font, taLeftJustify);
else ;
end;
end;