假设第2,4列右对齐,其他的左对齐procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
Area: TRect;
begin
with StringGrid1, StringGrid1.Canvas do begin
FillRect(Rect);
Area:= Rect;
InflateRect(Area, -2, -2);
if (ACol=1) or (ACol=3) then DrawText(Handle, PChar(Cells[ACol, ARow]),
Length(Cells[ACol, ARow]), Area, DT_RIGHT)
else TextRect(Rect, Rect.Left + 2, Rect.Top + 2, Cells[ACol, ARow]);
end;
end;
Rect: TRect; State: TGridDrawState);
var
Area: TRect;
begin
with StringGrid1, StringGrid1.Canvas do begin
FillRect(Rect);
Area:= Rect;
InflateRect(Area, -2, -2);
if (ACol=1) or (ACol=3) then DrawText(Handle, PChar(Cells[ACol, ARow]),
Length(Cells[ACol, ARow]), Area, DT_RIGHT)
else TextRect(Rect, Rect.Left + 2, Rect.Top + 2, Cells[ACol, ARow]);
end;
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货