아래와 같이 코딩을 했는데 글자가 안보이네요..
부탁드립니다.
with StringGrid1.Canvas do
begin
if (gdFixed in State) then
begin
Brush.Color := $00FF80FF;
Font.Color := clBlack;
FillRect(Rect);
end else if (StringGrid1.Cells[1,I] <> StringGrid1.Cells[7,I]) then
begin
Font.Color := clBlack;
Brush.Color := clPurple;
FillRect(Rect);
end else
begin
Font.Color := clWindowText;
Brush.Color := clWindow;
FillRect(Rect);
end;
end;
> 아래와 같이 코딩을 했는데 글자가 안보이네요..
> 부탁드립니다.
> with StringGrid1.Canvas do
> begin
> if (gdFixed in State) then
> begin
> Brush.Color := $00FF80FF;
> Font.Color := clBlack;
> FillRect(Rect);
> end else if (StringGrid1.Cells[1,I] <> StringGrid1.Cells[7,I]) then
> begin
> Font.Color := clBlack;
> Brush.Color := clPurple;
> FillRect(Rect);
> end else
> begin
> Font.Color := clWindowText;
> Brush.Color := clWindow;
> FillRect(Rect);
> end;
> end;
//////////////////////////////////////////////////////////////////
FillRect으로 셀을 채운후 글자는 TextRect로 다시 써야보입니다
일단 아래것을 참고해보세요
procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
begin
with TDBGrid(Sender) do begin
if (SelectedRows.CurrentRowSelected) then begin //현선택된줄만 색칠하기
Canvas.Brush.Color := clYellow;
Canvas.Font.Color := clBlack;
Canvas.FillRect(Rect);
//필드타입에 따라 다시쓰는 위치를 조정하세요.
if Field.DataType = ftString then
canvas.TextRect(Rect, Rect.Left + 2, Rect.Top, Field.AsString)
else
canvas.TextRect(Rect, Rect.Right - canvas.TextWidth(Field.AsString)
- 3, Rect.Top, Field.AsString)
end;
end;
end;