procedure TfrmShain.StringGrid1DrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
var
xpos: Integer;
begin
//セル寄せ
if gdFixed in State then
begin
SetTextAlign(StringGrid1.Canvas.Handle, TA_CENTER or TA_TOP);
xpos := (Rect.Left + Rect.Right) div 2;
end
else
begin
case ACol of
1,5: //中央寄せ
begin
SetTextAlign(StringGrid1.Canvas.Handle, TA_CENTER or TA_TOP);
xpos := (Rect.Left + Rect.Right) div 2;
end;
6: //右寄せ
begin
SetTextAlign(StringGrid1.Canvas.Handle, TA_RIGHT or TA_TOP);
xpos := Rect.Right -2;
end;
else //左寄せ
SetTextAlign(StringGrid1.Canvas.Handle, TA_LEFT or TA_TOP);
xpos := Rect.Left + 2;
end;
end;
ExtTextOut(StringGrid1.Canvas.Handle, xpos, Rect.Top + 2,
ETO_CLIPPED or ETO_OPAQUE, @Rect, PChar(StringGrid1.Cells[ACol, ARow]),
Length(StringGrid1.Cells[ACol, ARow]), nil);
end;
|