문제

I'm using Delphi XE2, is there a way to set bold font style on part of the text in DBGrid? For example, when I search for something, I want something like this.

enter image description here

Is it possible to do this?

도움이 되었습니까?

해결책

procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
  if (Column.Field.FieldName = 'Pay') then
  begin
    if Column.Field.AsString = 'yes' then
    begin
      dbgrid1.Canvas.Font.Color := clBlue;
      dbgrid1.Canvas.Font.Style :=[fsBold];
      dbgrid1.Canvas.FillRect(Rect);
      dbgrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
    end
    else
    begin
      dbgrid1.Canvas.Font.Color:= clRed;
      dbgrid1.Canvas.FillRect(Rect);
      dbgrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
    end;
  end;
end;

다른 팁

To solve this problem, set the value of the propertie DefaultDrawing of the DBGrid to False.

I had the same problem for me and solved .

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top