Board index » delphi » How to center text in a stringgrid ?

How to center text in a stringgrid ?


2004-07-10 02:01:03 AM
delphi90
Hi, all!
Is it fairly easy to center the text in the standard TStringGrid ? If
so, how ?
Thanks
Stan Campsmith
 
 

Re:How to center text in a stringgrid ?

On 09 Jul 2004, "Stanwood Campsmith" <XXXX@XXXXX.COM>writes:
Quote
Is it fairly easy to center the text in the standard TStringGrid ? If
so, how ?
You simply have to draw the text yourself using the OnDrawCell event
handler:
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
StringGrid1.Canvas.FillRect(Rect);
DrawText(StringGrid1.Canvas.Handle,
PAnsiChar(StringGrid1.Cells[ACol,ARow]), -1, Rect, DT_CENTER);
end;
--
-Mike (TeamB)
 

Re:How to center text in a stringgrid ?

Mike Williams [TeamB] writes:
Quote

You simply have to draw the text yourself using the OnDrawCell event
handler:
Thanks, Mike!