StringGrid Row색칠/정렬 하기
procedure Tfrm_xxx.Grid_ListDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
var
Ls_mt_kbn : String;
LeftPos: Integer;
TopPos : integer;
CellStr: string;
begin
Ls_mt_kbn := Grid_List.Cells[16,ARow];
if (ACol >= Grid_List.FixedCols) and (ARow >= Grid_List.FixedRows) then
with Grid_List.Canvas do
begin
if Ls_mt_kbn = 'M' then
Brush.Color := clSkyBlue;
if Ls_mt_kbn = 'N' then
Brush.Color := clAqua;
CellStr := Grid_List.Cells[ACol, ARow];
TopPos := ((Rect.Top - Rect.Bottom - TextHeight(CellStr)) div 2) + Rect.Bottom;
case ACol of
{왼쪽정렬}
0,1 : LeftPos := Rect.Left + 5;
{가운데정렬}
2,8,11,12,13 : LeftPos := ((Rect.Right - Rect.Left TStringGrid(Sender).Canvas.TextWidth(CellStr)) div 2) + Rect.Left;
{오른쪽정렬}
else LeftPos := (Rect.Right - Rect.Left TStringGrid(Sender).Canvas.TextWidth(CellStr)) + Rect.Left - 6;
end;
FillRect(Rect);
TextOut(LeftPos, TopPos, CellStr);
end;
end;
'Delphi Tip > 그리드' 카테고리의 다른 글
DBGrid 동일값 셀병합(컬럼머지) (0) | 2024.05.27 |
---|---|
퀀텀 그리드 컬럼 동적 생성 (0) | 2024.05.03 |
델파이 퀀텀 그리드 헤더 색깔 변경 (0) | 2021.09.24 |
StringGrid 팁 (0) | 2021.09.23 |
델파이 퀀텀그리드 출력 리스트 읽기 (0) | 2021.09.17 |
댓글