procedure TForm1.Grid_CBGTDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
CellStr : String;
LeftPos : Integer;
begin
if ARow = 0 then // 가운데 정렬
begin
with TStringGrid(Sender).Canvas do
begin
CellStr := TStringGrid(Sender).Cells[ACol, ARow];
LeftPos := ((Rect.Right - Rect.Left - TStringGrid(Sender).Canvas.TextWidth(CellStr)) div 2) + Rect.Left;
FillRect(Rect);
TextOut(LeftPos, Rect.Top + 2, CellStr);
end;
end;
if (ARow <> 0 ) And ( (aCol >= 2) and (aCol <= 3) ) then //오른쪽 정렬
begin
with TAdvStringGrid(Sender).Canvas do
begin
CellStr := TAdvStringGrid(Sender).Cells[ACol, ARow];
LeftPos := Rect.Right - TAdvStringGrid(Sender).Canvas.TextWidth(CellStr);
FillRect(Rect);
TextOut(LeftPos-2, Rect.Top+2, CellStr);
end;
end;
end;
Rect: TRect; State: TGridDrawState);
var
CellStr : String;
LeftPos : Integer;
begin
if ARow = 0 then // 가운데 정렬
begin
with TStringGrid(Sender).Canvas do
begin
CellStr := TStringGrid(Sender).Cells[ACol, ARow];
LeftPos := ((Rect.Right - Rect.Left - TStringGrid(Sender).Canvas.TextWidth(CellStr)) div 2) + Rect.Left;
FillRect(Rect);
TextOut(LeftPos, Rect.Top + 2, CellStr);
end;
end;
if (ARow <> 0 ) And ( (aCol >= 2) and (aCol <= 3) ) then //오른쪽 정렬
begin
with TAdvStringGrid(Sender).Canvas do
begin
CellStr := TAdvStringGrid(Sender).Cells[ACol, ARow];
LeftPos := Rect.Right - TAdvStringGrid(Sender).Canvas.TextWidth(CellStr);
FillRect(Rect);
TextOut(LeftPos-2, Rect.Top+2, CellStr);
end;
end;
end;