StringGrid文字居中

procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
Str: String;
R: TRect;
begin
with StringGrid1 do
begin
Canvas.FillRect(Rect);
Str := Cells[ACol,ARow];
R := Rect;
DrawText(Canvas.Handle,PChar(Str),Length(Str),r,DT_CENTER or DT_SINGLELINE or DT_VCENTER); //文字居中
end;
end;

你可能感兴趣的:(String)