Reputation: 57
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.
Is it possible to do this?
Upvotes: 2
Views: 6790
Reputation: 1498
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;
Upvotes: 6
Reputation: 11
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 .
Upvotes: 1