Jump to content
과거의 기술자료(읽기 전용): https://tech.devgear.co.kr ×
과거의 기술자료(읽기 전용): https://tech.devgear.co.kr

[TMS] TAdvStringGrid 기능소개 - cell 항목 데이터 색상 지정 방법


Recommended Posts

image.png

TAdvStringGrid에 입력된 데이터 종류에 따라 폰트 색상을 지정 하는 방법에 대한 샘플 입니다.

값을 양수와 음수로 구별하여 각기 다른 색상을 지정 하게 하였고 앱이 실행된 런타임 상태에서도 색상을 변경 할 수 있게 합니다.

TAdvStringGrid 의 OnGetCellColor 메소드가 사용 되었습니다.

procedure TForm1.Button1Click(Sender: TObject);
var
  i, j: Integer;
begin
  for i := 1 to AdvStringGrid1.RowCount - 1 do
    for j := 1 to AdvStringGrid1.ColCount - 1 do
      AdvStringGrid1.Ints[j, i] := Random(1000) - 500;
end;

procedure TForm1.AdvStringGrid1GetCellColor(Sender: TObject; ARow, ACol: Integer; AState: TGridDrawState; ABrush: TBrush; AFont: TFont);
begin
  if AdvStringGrid1.Cells[ACol, ARow] <> '' then
    if AdvStringGrid1.Ints[ACol, ARow] < 0 then
    begin
      ABrush.Color := ColorGrid2.BackgroundColor;
      AFont.Color := ColorGrid2.ForegroundColor;
    end
    else
    begin
      Abrush.Color := Colorgrid1.BackgroundColor;
      AFont.Color := Colorgrid1.ForegroundColor;
      AFont.Style := [fsBold];
    end;
end;

procedure TForm1.ColorGrid1Change(Sender: TObject);
begin
  AdvStringGrid1.Invalidate;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Button1Click(Sender);
end;

 

 

이 댓글 링크
다른 사이트에 공유하기

이 토의에 참여하세요

지금 바로 의견을 남길 수 있습니다. 그리고 나서 가입해도 됩니다. 이미 회원이라면, 지금 로그인하고 본인 계정으로 의견을 남기세요.

Guest
이 토픽(기고/질문)에 답하기

×   서식있는 텍스트로 붙여넣기.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   이전에 작성한 콘텐츠가 복원되었습니다..   편집창 비우기

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

중요한 정보

이용약관 개인정보보호정책 이용규칙 이 사이트가 더 잘 작동하기 위해 방문자의 컴퓨터에 쿠키가 배치됩니다. 쿠키 설정 변경에서 원하는 설정을 할 수 있습니다. 변경하지 않으면 쿠키를 허용하는 것으로 이해합니다.