You are not logged in.
i want to set the font as Bold in the TSQLTableToGrid row for some special condition.
this code is working with font as Bold, but i can not select the row.
procedure TBPBaseMainForm.DoOnDrawCellEvent(Sender: TObject; ACol, ARow: Longint; Rect: TRect; State: TGridDrawState);
var T2G: TSQLTableToGrid;
ATIndex: Integer;
ATValue: Integer;
begin
T2G:= TSQLTableToGrid.From(TDrawGrid(Sender));
if not(gdFocused in State) then begin
ATIndex:= T2G.Table.FieldIndex('AccountType');
ATValue:= T2G.Table.GetAsInteger(ARow,ATIndex);
with TDrawGrid(Sender) do begin
if ATValue = 3 then
Canvas.Font.Style:= Canvas.Font.Style + [fsBold]
else
Canvas.Font.Style:= Canvas.Font.Style - [fsBold];
end;
end;
end;
what is missing?
Offline
Solved.
I just set the DefaultDrawing to True after Setting Canvas.Font.Style
procedure TBPBaseMainForm.DoOnDrawCellEvent(Sender: TObject; ACol, ARow: Longint; Rect: TRect; State: TGridDrawState);
var T2G: TSQLTableToGrid;
ATIndex: Integer;
ATValue: Integer;
begin
T2G:= TSQLTableToGrid.From(TDrawGrid(Sender));
ATIndex:= T2G.Table.FieldIndex('AccountType');
ATValue:= T2G.Table.GetAsInteger(ARow,ATIndex);
// if not(gdFixed in State) then
with TDrawGrid(Sender).Canvas do begin
if ATValue = 3 then
Font.Style:= Font.Style + [fsBold]
else
Font.Style:= Font.Style - [fsBold];
TDrawGrid(Sender).DefaultDrawing:= True; //Just add this line;
end;
end;
But i loss the look and feel of the header.
any idea?
thanks
Offline
not working with checking ARaw>0.
...
if ARow > 0 then
with TDrawGrid(Sender).Canvas do begin
if ATValue = 3 then
Font.Style:= Font.Style + [fsBold]
else
Font.Style:= Font.Style - [fsBold];
// if ARow > 0 then
TDrawGrid(Sender).DefaultDrawing:= True;
end;
...
Offline